git - 备份 GitHub 存储库

标签 git backup

在满足以下要求的情况下,创建托管在 GitHub 上的 git 存储库的本地备份的最佳方法是什么?

  1. 本地备份应该是一个裸仓库。

  2. 备份应包括所有分支。

  3. (增量)更新备份应该很容易。

基本上,我想要一个完美的镜像,可以轻松更新。因此,命令

git clone --mirror git://github.com/...

想到了,但据我所知,这不允许轻松更新(我必须删除并重新创建我的本地备份)。此外,git clone 的镜像选项似乎是最近才出现的,我正在使用的一些系统上没有它(这些系统运行的 git 版本稍旧)。

对于此类问题,您推荐的解决方案是什么?

最佳答案

我不确定它能否满足您的所有要求,但您可以查看 git bundle

git bundle

This command provides support for git fetch and git pull to operate by packaging objects and references in an archive at the originating machine, then importing those into another repository using git fetch and git pull after moving the archive by some means

我喜欢该解决方案的一点是生成的单个文件,其中包含我想要的内容

git bundle will only package references that are shown by git-show-ref: this includes heads, tags, and remote heads.

machineA$ git bundle create file.bundle master

备注:Kent Fredric在评论中提到了 git rev-list 的一个微妙之处:

--all

Pretend as if all the refs in $GIT_DIR/refs/ are listed on the command line as <commit>.

他补充说:

your current bundle will only bundle parents of the commit, you'd probably need to specify --all to get a complete bundle of everything (branches that are descendant of master).

查看区别:

$ git bundle create /tmp/foo master
$ git bundle create /tmp/foo-all --all
$ git bundle list-heads /tmp/foo
$ git bundle list-heads /tmp/foo-all

关于git - 备份 GitHub 存储库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1251713/

相关文章:

git - Heroku pull 私有(private) github 存储库

git p4 从裸存储库提交?

linux - 如何创建 .git 文件

git - Bonobo Git 服务器是否提供分支级别的读/写访问权限?

java - 删除超过 30 天的 server.log.yyyy-mm-dd jboss eap 6.2 standalone

kubernetes - Kubernetes手动备份

bash - bash 脚本中 sqlite 的安全副本

git - git 中的分支描述,续

svn - 将 SVN 存储库备份到 FTP 服务器的好方法是什么?

SQL Server : how to query when the last transaction log backup has been taken?