restoring git repository from bundle backup

十年热恋 提交于 2019-12-02 20:15:32
fbicknel

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. :)

masterdany88

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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!