4

当我想创建一个新分支并通过以下方式完成时,我在我的“主”分支中:

$ git checkout -b od_newstructure
Switched to a new branch 'od_newstructure'

我提交了一些更改并将这个新分支添加到远程并开始跟踪

$ git commit
$ git branch -u origin/od_newstructure
Branch od_newstructure set up to track remote branch od_newstructure from origin.
$ .. some other work including git pull and git push

我现在想切换回master。所以我做了

git checkout master
Switched to branch 'master'

但是后来,master似乎不再跟踪origin/master了!

$ git branch -vv
* master          d1db2e3 Subdivided into several namespaces
  od_newstructure d1db2e3 [origin/od_newstructure] Subdivided into several namespaces

它也被 git pull 验证

$ git pull
There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details

我的问题是为什么当我切换到新的跟踪分支时,以前的跟踪分支会丢失其跟踪信息?这是默认和合理的行为吗?git branch -u每次切换到跟踪分支时都必须添加上游吗?

4

0 回答 0