简体   繁体   English

在git中跟踪分支和上游分支有什么区别?

[英]What's the difference between tracking branch and upstream branch in git?

Or what's the different between those two commands? 还是这两个命令有什么不同? What does "tracking" refer to? “跟踪”指的是什么? How about "upstream"? “上游”怎么样? Are the two actions different? 两种动作不同吗?

git branch --track [branch] [remote-branch]  
git branch --set-upstream [branch] [remote-branch]  

thx~ 谢谢〜

The idea behind both commands is that you'd like to track the changes in a remote branch. 这两个命令背后的想法是,您想跟踪远程分支中的更改。

git branch --track [branch] [remote-branch]

Creates a local branch from the remote-branch and sets the remote-branch as its upstream in order to track differences. 从远程分支创建本地分支,并将远程分支设置为其上游,以跟踪差异。 This is the default behavior when branching off of a remote branch and can be controlled using the branch.autoSetupMerge configuration variable. 这是分支到远程分支时的默认行为,可以使用branch.autoSetupMerge配置变量进行控制。

git branch --set-upstream [branch] [remote-branch]

Updates the upstream branch of a local branch to track differences to the remote-branch. 更新本地分支的上游分支以跟踪到远程分支的差异。 If the local branch didn't yet exist, the above two commands would be equivalent. 如果本地分支尚不存在,则以上两个命令将等效。 The main difference is that --set-upstream doesn't necessarily modify the branch pointer. 主要区别在于--set-upstream不一定修改分支指针。

For further information, you should review the git branch documentation . 有关更多信息,您应该查看git分支文档

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

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