如何更新 git clone --mirror?
我已经创建了一个 git 存储库来镜像实时站点(这是一个非裸 git 存储库):
git clone --mirror ssh://[email protected]/path/to/repo
现在,为了使此镜像克隆更新其远程源的所有更改,我必须使用哪个或哪些命令?
我想保持所有内容的更新:提交、参考、钩子、分支等。
谢谢!
I have created a git repository to mirror a live site (which is a non-bare git repository):
git clone --mirror ssh://[email protected]/path/to/repo
Now, to keep this mirror clone updated with all changes from its remote origin, which command or commands I must use?
I'd like to keep everything updated: commits, refs, hooks, branches, etc.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这是您需要在镜像上执行的命令:
This is the command that you need to execute on the mirror:
关于提交、引用、分支和“等等”,Magnus 的回答很有效(
git 远程更新
)。但不幸的是,没有办法像我想要的那样
克隆
/镜像/更新
钩子...我发现了这个非常有趣的线程克隆/镜像挂钩:
http://kerneltrap.org/mailarchive/ git/2007/8/28/256180/thread
我了解到:
挂钩不被视为存储库内容的一部分。
还有更多数据,例如
.git/description
文件夹,它不会被克隆,就像钩子一样。出现在
hooks
目录中的默认挂钩来自TEMPLATE_DIR
git 上有这个有趣的
template
功能。因此,考虑到我的镜像的用途(仅用于其他克隆的备份+源),我可以忽略这个“克隆钩子”,或者采用 rsync 策略。
好吧...我会忘记钩子克隆,并坚持使用 git 远程更新 方式。
clone
/update
流程管理,而且 stashes、rerere 等也不受管理......因此,对于严格备份、rsync 或类似的方法确实是可行的方法。由于这在我的情况下并不是真正必要的(我可以承受没有钩子、隐藏等的情况),就像我说的,我将坚持远程更新
。谢谢!改进了我自己的“git-fu”......:-)
Regarding commits, refs, branches and "et cetera", Magnus answer just works (
git remote update
).But unfortunately there is no way to
clone
/ mirror /update
the hooks, as I wanted...I have found this very interesting thread about cloning/mirroring the hooks:
http://kerneltrap.org/mailarchive/git/2007/8/28/256180/thread
I learned:
The hooks are not considered part of the repository contents.
There is more data, like the
.git/description
folder, which does not get cloned, just as the hooks.The default hooks that appear in the
hooks
dir comes from theTEMPLATE_DIR
There is this interesting
template
feature on git.So, I may either ignore this "clone the hooks thing", or go for a
rsync
strategy, given the purposes of my mirror (backup + source for other clones, only).Well... I will just forget about hooks cloning, and stick to the
git remote update
way.clone
/update
process, but also stashes, rerere, etc... So, for a strict backup,rsync
or equivalent would really be the way to go. As this is not really necessary in my case (I can afford not having hooks, stashes, and so on), like I said, I will stick to theremote update
.Thanks! Improved a bit of my own "git-fu"... :-)
请参阅此处: Git 不会克隆后续的所有分支克隆?
如果您确实希望通过拉取分支而不是
push --mirror
来实现这一点,您可以在这里查看:"获取 -- git bare 存储库中的“all”不会将本地分支同步到远程分支
这个答案提供了如何相对轻松地实现这一目标的详细步骤:
See here: Git doesn't clone all branches on subsequent clones?
If you really want this by pulling branches instead of
push --mirror
, you can have a look here:"fetch --all" in a git bare repository doesn't synchronize local branches to the remote ones
This answer provides detailed steps on how to achieve that relatively easily: