问题描述
我知道本地分支机构可以跟踪远程分支机构,但是本地分支机构也有可能跟踪另一个本地分支机构.一个用例是什么?
I know that local branches can track remote branches, but there is also the possibility that a local branch tracks another local branch. What is a use-case for this?
推荐答案
实际用途:
我有一个上游存储库,还有一个跟踪该远程服务器的本地分支.我开始研究一个主要的功能",这将需要进行一堆更改才能实现,但是我还不想在上游(可能永远)公开这项工作.
I have an upstream repository, and a local branch tracking that remote. I start working on a major "feature" which will require a mess of changes to implement, but I don't yet want to expose the work upstream (potentially, ever).
因此,我创建了一个跟踪我的跟踪分支的本地分支.现在,我有 origin/master
, master
跟踪它和 feature
跟踪 master
.因此,每当更新 origin/master
时,我都可以保持 origin/master
为最新,然后在本地 master
.
So I create a local branch tracking my tracking branch. Now I have origin/master
, master
tracking that, and feature
tracking master
. So whenever origin/master
is updated, I can keep origin/master
up to date, and then apply my feature-specific changes on top of any uncommitted changes in the local master
.
功能
不直接跟踪 origin/master
的原因是它可能取决于本地 master
分支中的工作尚未承诺,但还不足以保证其自己的功能分支.
The reason why feature
isn't directly tracking origin/master
is that it may depend on work in the local master
branch which isn't yet committed but isn't major enough to warrant its own feature branch.
这对于多个独立功能也很有用- basefeature
跟踪 master
,而 subfeature
跟踪 basefeature
.
This could also be useful for multiple independent features - basefeature
tracks master
, and subfeature
tracks basefeature
.
这篇关于Git:本地分支跟踪其他本地分支的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!