i created backups of my git repository like in How to backup a local Git repository? proposed with
git bundle create /tmp/foo-all --all
I can see all refs are in there, including a remote ref created by git-svn. Now I can't figure out how to restore this bundle to a local repository again. I am quite quite sure i've done it already once. I tried git-clone but that gives me a just a repository with my backup bundle as remote repo.
I also tried
git init
git bundle unbundle /tmp/foo --all
but this just lists all references...
Verifying the bundle gives:
$ git bundle verify $somewhere/foo.bundle
The bundle contains 12 refs
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx refs/heads/xxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx refs/heads/xxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx refs/heads/xxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx refs/heads/xxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx refs/heads/xxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx refs/heads/xxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx refs/heads/xxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx refs/heads/master
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx refs/heads/xxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx refs/heads/xxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx refs/remotes/git-svn
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx HEAD
The bundle requires these 0 ref
$somewhere/foo.bundle is okay
Short answer:
$ git bundle verify $somewhere/foo.bundle
$ git clone $somewhere/foo.bundle
Cloning into 'foo'...
Receiving objects: 100% (10133/10133), 82.03 MiB | 74.25 MiB/s, done.
Resolving deltas: 100% (5436/5436), done.
$ cd foo
$ git status
...
Lazy Badger said this, but it's in the last paragraph. :)
I newer version of git is enough to do:
git clone bundle.file
the whole commands:
mkdir ~/git
cd ~/git
git clone /path/to/bundle.file
It will restore completely Your's git bare repository content (which will compile as it is normal source). You don't need any other file. The bundle file is enough.
It is wise to always verify You bundle file before unbundle as follow:
git bundle verify /path/to/bundle.file
Bundle contain not files, but deltas , you need the base in order to recreate the file content. You have to clone first, unbundle later. Init instead of clone allowed only in case, where bundle requires 0 refs
Don't ignore git bundle verify
before unbundling
git-bundle(1) - Linux man page
Used to check that a bundle file is valid and will apply cleanly to the current repository. This includes checks on the bundle format itself as well as checking that the prerequisite commits exist and are fully linked in the current repository. git bundle prints a list of missing commits, if any, and exits with a non-zero status.
If you are creating the repository, then you can clone from the bundle as if it were a remote repository instead of creating an empty repository and then pulling or fetching objects from the bundle
This should be the answer git clone -b main <bundleName.bundle>
git bundle unbundle /tmp/foo --all
but this just lists all references...
Actually, it now can do more than that:
Git 2.34 (Q4 2021) adds progress display to " git bundle unbundle
" ( man ) ".
In addition to git bundle verify
mentioned in this answer , it will show you at least what is going on.
See commit d941cc4 , commit f46c46e , commit 7366096 (05 Sep 2021), and commit 0834257 (26 Aug 2021) by Ævar Arnfjörð Bjarmason ( avar
) .
(Merged by Junio C Hamano -- gitster
-- in commit 67fc02b , 20 Sep 2021)
bundle
: show progress on "unbundle"Signed-off-by: Ævar Arnfjörð Bjarmason
The "unbundle" command added in 2e0afaf ("Add git-bundle: move objects and references by archive", 2007-02-22, Git v1.5.1-rc1 -- merge ) did not show progress output, even though the underlying API learned how to show progress in be042af ("Teach progress eye-candy to
fetch_refs_from_bundle()
", 2011-09-18, Git v1.7.8-rc0 -- merge ).Now we'll show "Unbundling objects" using the new
--progress-title
option togit index-pack
" ( man ) , to go with its existing "Receiving objects" and "Indexing objects" (which it shows when invoked with "--stdin
", and with a pack file, respectively).Unlike "
git bundle create
" ( man ) we don't handle "--quiet
" here, nor "--all-progress
" and "--all-progress-implied
".
Those are all specific to "create" (and "verify", in the case of "--quiet
").The structure of the existing documentation is a bit unclear, eg the documentation for the "
--quiet
" option added in 79862b6 ("bundle-create
: progress output control", 2019-11-10, Git v2.25.0-rc0 -- merge listed in batch #2 ) only describes how it works for "create
", and not for "verify
".
That and other issues in it should be fixed, but I'd like to avoid untangling that mess right now.
Let's just support the standard "--no-progress
" implicitly here, and leave cleaning up the general behavior of "git bundle
" ( man ) for a later change.
git bundle
now includes in its man page :
'git bundle' unbundle [--progress] <file> [<refname>...]
I tried git-clone but that gives me a just a repository with my backup bundle as remote repo.
Bundle doesn't store original repository URL. You have to specify it manually:
git clone foo.bundle
cd foo
git remote set-url origin url-to-original-repository
Now you can fetch from and push to original repository.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.