我有一个正在处理的项目,当前在GitHub的存储库中。
我正在做我的学位课程的一部分,我将很快将其移交给客户
我想知道是否有一种方法可以导出包括所有分支和相关历史记录在内的整个存储库,以便可以在将其存储到将来的开发人员之前进行存储?
(1)使用git archive(用于备份一个分支),类似于以下命令(假设您位于Git本地存储库中):
git archive master --format=zip --output=java_exmamples.zip
Run Code Online (Sandbox Code Playgroud)
您将看到文件java_exmamples.zip
(在同一文件夹中)是master分支的备份。
(2)使用git bundle(用于备份所有分支)
一个真实的例子:
git clone --mirror https://github.com/donhuvy/java_examples.git
cd java_examples.git/
git bundle create repo.bundle --all
Run Code Online (Sandbox Code Playgroud)
repo.bundle
是您需要的文件(完整备份)在同一目录中。
如何从文件还原repo.bundle
:
git clone repo.bundle
Run Code Online (Sandbox Code Playgroud)
参考
https://git-scm.com/docs/git-archive
https://git-scm.com/docs/git-bundle
http://rypress.com/tutorials/git/tips-and-tricks#bundle-the-repository