如何更新 git clone --mirror?

发布于 2024-11-09 21:52:40 字数 338 浏览 0 评论 0原文

我已经创建了一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

冷弦 2024-11-16 21:52:40

这是您需要在镜像上执行的命令:

git remote update

This is the command that you need to execute on the mirror:

git remote update
一袭水袖舞倾城 2024-11-16 21:52:40

关于提交、引用、分支和“等等”,Magnus 的回答很有效(git 远程更新)。

但不幸的是,没有办法像我想要的那样克隆/镜像/更新钩子...

我发现了这个非常有趣的线程克隆/镜像挂钩:

http://kerneltrap.org/mailarchive/ git/2007/8/28/256180/thread

我了解到:

  • 挂钩不被视为存储库内容的一部分。

  • 还有更多数据,例如 .git/description 文件夹,它不会被克隆,就像钩子一样。

  • 出现在 hooks 目录中的默认挂钩来自 TEMPLATE_DIR

  • git 上有这个有趣的 template 功能。

因此,考虑到我的镜像的用途(仅用于其他克隆的备份+源),我可以忽略这个“克隆钩子”,或者采用 rsync 策略。

好吧...我会忘记钩子克隆,并坚持使用 git 远程更新 方式。

  • Sehe 刚刚指出,不仅“hooks”不受 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 the TEMPLATE_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.

  • Sehe has just pointed out that not only "hooks" aren't managed by the 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 the remote update.

Thanks! Improved a bit of my own "git-fu"... :-)

泪是无色的血 2024-11-16 21:52:40

请参阅此处: 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:

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文