本地Git克隆可以被视为是从其克隆的回购的完整备份吗? [英] Can a local Git clone be considered a complete backup of the repo it was cloned from?

查看:95
本文介绍了本地Git克隆可以被视为是从其克隆的回购的完整备份吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我已经使用以下方法将Git存储库克隆到本地磁盘:



pre $ g $ clone用户名@ git.example.com: someproject.git

现在假设 git.example.com 没有被备份,并且它在辉煌的光芒中倒下了。我的克隆是否包含重建丢失的远程回购所需的一切? 最终备份部分//www-cs-students.stanford.edu/~blynn/gitmagic/rel =noreferrer> Git Magic 表明答案是是的,但我不清楚。

请注意,我并没有问我的本地克隆是否支持 master 分支?我询问我的本地克隆是否可以被视为远程回购中包含的完成 的完整备份;所有分支,所有标签,所有。例如,远程分支机构在本地回购中没有被跟踪的情况如何?

为了进一步混淆问题,存在 git clone - -mirror 向我建议我的本地克隆应该被认为是远程repo的完整备份。

解决方案

克隆可以被认为是远程仓库中所有数据的完整备份,但不一定是元数据(这就是 - mirror 开关进来)。您的克隆将包含存储库以任何方式引用的所有提交,树,blob,分支和标记对象。这意味着您的备份将包含您的所有源代码,历史记录和相关分支或标记。



- mirror switch没有它,克隆将不包含在服务器上创建的遥控器之类的东西。这些在我希望我没有失去任何消息来源!中并不重要。样的方式,但他们可能是让你的服务器备份和运行就像是。



如果您有兴趣创建一个可以恢复到备份服务器像从来没有任何问题,那么你应该使用 - 镜像,但对于大多数情况下一个简单的克隆是好的。


Suppose I have cloned a Git repository to my local disk using:

git clone username@git.example.com:someproject.git

Now suppose that git.example.com is not being backed up, and it goes down in a blaze of glory. Does my clone contain everything necessary to rebuild the remote repo that was lost? The Ultimate Backups section of Git Magic suggests that the answer is "yes," but it isn't clear to me.

Note that I'm not asking "is my local clone a sufficient backup of the master branch?" I'm asking whether my local clone can be considered a complete backup of everything that was contained in the remote repo; all branches, all tags, everything. For example, what about remote branches that aren't tracked in the local repo?

To futher confuse the issue, the existence of git clone --mirror suggests to me that my local clone should not be considered a complete backup of the remote repo.

解决方案

A clone can be considered a full backup of all the data in your remote repository, but not necessarily the meta-data (that's where the --mirror switch comes in). Your clone will contain all the commit, tree, blob, branch, and tag objects that are in any way referenced by the repository. That means your backup will contain all your source code, history, and associated branches or tags.

The difference with the --mirror switch is that without it, the clone won't include things like remotes that have been created on the server. These are not important in a "I hope I haven't lost any source!" kind of way, but they may be for getting your server back up and running like it was.

If you're interested in creating a backup that can be restored onto the server like there was never any issue, then you should use --mirror, but for most scenarios a simple clone is fine.

这篇关于本地Git克隆可以被视为是从其克隆的回购的完整备份吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆