Von*_*onC 172
git bundle
Run Code Online (Sandbox Code Playgroud)
我喜欢这种方法,因为它只产生一个文件,更容易复制.
看到ProGit:一点欢乐.
另请参阅" 如何通过电子邮件向某人发送git存储库? "命令
git bundle create /tmp/foo-all --all
Run Code Online (Sandbox Code Playgroud)
详细说明:
git bundle
将只打包由git show-ref显示的引用:这包括头,标签和远程头.
目的地使用的基础非常重要.
可以谨慎行事,导致捆绑文件包含目标中已有的对象,因为在目的地解包时会忽略这些对象.
要使用该捆绑包,您可以克隆它,指定一个不存在的文件夹(在任何git仓库之外):
git clone /tmp/foo-all newFolder
Run Code Online (Sandbox Code Playgroud)
Kin*_*nch 55
什么只是克隆它?
git clone --mirror other/repo.git
Run Code Online (Sandbox Code Playgroud)
每个存储库都是其远程的备份.
fan*_*ous 21
扩展其他一些答案,这就是我所做的:
设置回购: git clone --mirror user@server:/url-to-repo.git
然后,当您要刷新备份时:git remote update
从克隆位置.
这会备份所有分支和标记,包括稍后添加的新分支和标记,但值得注意的是,删除的分支不会从克隆中删除(备份可能是一件好事).
这是原子的,因此没有简单副本会出现的问题.
见http://www.garron.me/en/bits/backup-git-bare-repo.html
Kim*_*kas 12
扩展KingCrunch和VonC的绝佳答案
我将它们结合在一起:
git clone --mirror git@some.origin/reponame reponame.git
cd reponame.git
git bundle create reponame.bundle --all
Run Code Online (Sandbox Code Playgroud)
之后,您将拥有一个reponame.bundle
可以轻松复制的文件。然后,您可以使用从其中创建一个新的普通git存储库git clone reponame.bundle reponame
。
请注意,git bundle
仅副本提交会在存储库中导致某些引用(分支或标记)。因此,纠结提交不会存储到分发包中。
该线程对于了解如何完成 git repos 的备份非常有帮助。我认为它仍然缺乏一些提示,信息或结论来为自己找到“正确的方法”(tm)。因此,在这里分享我的想法以帮助其他人,并将它们提交讨论以增强它们。谢谢。
所以从拿起原来的问题开始:
然后用典型的愿望丰富它并指定一些预设:
关于什么是“100%”备份的观点不同。这里有两个典型的。
git 是一个开发者工具,通过git clone --mirror
和支持这个观点git bundle --all
。
git gc
)git 是一个开发人员工具,它留给管理员。git 配置和操作系统配置的备份应该与内容的备份分开。
它们中的大多数是通用的备份。
git gc --auto
git bundle --all
git bundle verify
.git clone --mirror
git fsck
.A cold-copy backup can always do a full file backup: deny all accesses to the git repos, do backup and allow accesses again.
File backups cannot be done with active repos due to risk of corrupted data by on-going commits. A hot-copy provides a fixed state of an active repository for backup purposes. On-going commits do not affect that copy. As listed above git's clone and bundle functionalities support this, but for a "100% admin" backup several things have to be done via additional commands.
git bundle --all
to create full/incremental dump files of content and copy/backup configuration files separately.git clone --mirror
, handle and copy configuration separately, then do full file backup of mirror.
使用 git bundle 或 clone
复制 git 目录不是一个好的解决方案,因为它不是原子的。如果您有一个需要很长时间复制的大型存储库,并且有人推送到您的存储库,则会影响您的备份。克隆或制作捆绑包不会有这个问题。
IMO 的正确答案是git clone --mirror。这将完全备份您的回购。
Git clone mirror 会克隆整个仓库、notes、heads、refs 等,通常用于将整个仓库复制到新的 git 服务器。这将拉下所有分支和所有内容,整个存储库。
git clone --mirror git@example.com/your-repo.git
Run Code Online (Sandbox Code Playgroud)
通常克隆一个 repo 不包括所有分支,只包括 Master。
复制 repo 文件夹只会“复制”已拉入的分支……因此默认情况下,只有主分支或您之前签出的其他分支。
Git bundle 命令也不是您想要的:“bundle 命令会将通常使用 git push 命令通过网络推送的所有内容打包成一个二进制文件,您可以通过电子邮件将其发送给某人或放在闪存驱动器上,然后解绑到另一个存储库。” (来自git clone --mirror 和 git clone --bare 之间的区别是什么)
归档时间: |
|
查看次数: |
96656 次 |
最近记录: |