Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
206 views
in Technique[技术] by (71.8m points)

How to git bundle a complete repo

I need to transfer a complete repo to a new non-networked machine, preferable as a single file entity. The git bundle allows a git fetch, git pull style operation in a sneakernet environment but appears to assume that you already have a working version of the repo on the destination machine.

What is the right invocation to:

  1. Bundle all the branches in the current repo
  2. Start up the new repo on the destination directory, i.e. get the root commit correctly installed

I've sent a patch upstream to clarify:

`git clone` can use any bundle created without negative refspecs
(e.g., `new`, but not `old..new`).
If you want to match `git clone --mirror`, which would clone other
refs such as `refs/remotes/*`, use `--all`.
If you want to provide the same set of refs that a clone directly
from the source repository would get, use `--branches --tags` for
the `<git-rev-list-args>`.

So $ git bundle create repo.bundle --branches --tags best matches cloning.

$ git bundle create repo.bundle --all will provide a mirror image of your source machine, including it's remote refs.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

What is the right invocation to:

  • Bundle all the branches in the current repo

Simple:

$ git bundle create repo.bundle --all

Here repo.bundle is the name of bundle file you want to create. Note that --all would not include remote-tracking branches... just like ordinary clone wouldn't either.

  • Start up the new repo on the destination directory, i.e. get the root commit correctly installed

First, clone is just init + fetch (+ administrativia).

Second, you can use bundle file everywhere the repository URL can be used, so you can simply clone from a bundle file:

$ git clone repo.bundle

This would create repo as a git repository.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...