简体   繁体   English

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

[英]Remote branch with multiple local tracking branches

Is it possible, that a remote branch can have multiple local tracking branches? 远程分支可以有多个本地跟踪分支吗? Or would that confuse the push/pull commands? 或者这会混淆推/拉命令?

It's fine, sort of. 这很好,有点儿。

Git looks up remote information for given local branches, not the other way around. Git查找给定本地分支的远程信息,而不是相反。 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 , ie push local branches to remote branches of the same name. push.default的默认设置是matchingpush.default本地分支推送到同名的远程分支。 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! 但是,如果你将push.default设置为tracking ,它将再次为每个本地分支查找正确的远程分支 - 但如果你的本地分支不相同,它们显然不能全部被推到那里! Probably if you're thinking about multiple local branches tracking the same remote, you simply don't want to set push.default to tracking. 可能如果您正在考虑跟踪同一个遥控器的多个本地分支,您根本不想将push.default设置为跟踪。

there would be no confusion. 不会有混乱。 If anything, it depends on you and how well you understand the way the DAG, branches and remotes work. 如果有的话,这取决于你以及你对DAG,分支和遥控器工作方式的理解程度。 :) :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM