具有多个本地跟踪分支的远程分支

发布于 2024-10-29 18:49:48 字数 40 浏览 12 评论 0原文

一个远程分支是否可以有多个本地跟踪分支?或者这会混淆推/拉命令吗?

Is it possible, that a remote branch can have multiple local tracking branches? Or would that confuse the push/pull commands?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

小耗子 2024-11-05 18:49:48

有点好。

Git 查找给定本地分支的远程信息,而不是相反。也就是说,远程分支没有多个本地跟踪分支。多个本地分支具有相同的远程跟踪分支。

当您拉取时,它会获取适当的远程分支,更新相应的远程跟踪分支,然后合并它。一切都会好起来的;仅涉及一个分支及其跟踪分支。我怀疑这是你的真实用例。

当您推送时,通常根本不会使用跟踪信息。 push.default的默认设置是matching,即将本地分支推送到同名的远程分支。在这种情况下,一切都会好起来,平淡无奇。

但是,如果您将 push.default 设置为 tracking,它会再次为每个本地分支查找正确的远程分支 - 但如果您的本地分支不是一样的,显然不可能全部都推到那里去!如果您正在考虑多个本地分支跟踪同一个远程分支,那么您可能根本不想将 push.default 设置为跟踪。

It's fine, sort of.

Git looks up remote information for given local branches, not the other way around. That is, the remote branch doesn't have multiple local tracking branches. Multiple local branches have the same remote tracking branch.

When you pull, it fetches the appropriate remote branch, updates the corresponding remote tracking branch, and merges it. Everything will go just fine; only that one branch and its tracked branch are involved. I suspect this is your real use case.

When you push, normally tracking information isn't used at all. The default setting of push.default is matching, i.e. push local branches to remote branches of the same name. In this case, everything will still be fine, trivially so.

However, if you've set push.default to tracking, it'll again look up the right remote branch for each local one - but if your local branches aren't identical, they obviously can't all be pushed there! Probably if you're thinking about multiple local branches tracking the same remote, you simply don't want to set push.default to tracking.

暮年慕年 2024-11-05 18:49:48

就不会有混乱了。如果有的话,这取决于您以及您对 DAG、分支和远程工作方式的理解程度。 :)

there would be no confusion. If anything, it depends on you and how well you understand the way the DAG, branches and remotes work. :)

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