git 如何处理来自两个不同远程仓库的相同分支名称?
How does git deal with identical branch names from two different remote repo?
如果我使用 git remote add 为一个 repo 设置了两个 remote,并且这两个 repo 包含一个同名的分支。当我使用 git checkout?
切换到它时,git 如何知道我打算使用哪个 repo 的哪个分支
How does git know which branch of which repo I intend to use when I switch to it using git checkout?
没有。通常,如果存在歧义,例如在这种情况下,两个遥控器("origin" 和 "upstream2")都有一个 devel
分支:
$ git branch -a
* master
remotes/origin/HEAD -> origin/master
remotes/origin/devel
remotes/origin/master
remotes/upstream2/devel
remotes/upstream2/master
如果我只是尝试 git checkout devel
我得到:
$ git checkout devel
error: pathspec 'devel' did not match any file(s) known to git.
我需要说清楚:
$ git checkout -b devel remotes/upstream2/devel
Branch devel set up to track remote branch devel from upstream2 by rebasing.
Switched to a new branch 'devel'
将此与我只有一个遥控器的情况进行比较:
$ git branch -a
* master
remotes/origin/HEAD -> origin/master
remotes/origin/devel
remotes/origin/master
然后:
$ git checkout devel
Branch devel set up to track remote branch devel from origin by rebasing.
Switched to a new branch 'devel'
如果我使用 git remote add 为一个 repo 设置了两个 remote,并且这两个 repo 包含一个同名的分支。当我使用 git checkout?
切换到它时,git 如何知道我打算使用哪个 repo 的哪个分支How does git know which branch of which repo I intend to use when I switch to it using git checkout?
没有。通常,如果存在歧义,例如在这种情况下,两个遥控器("origin" 和 "upstream2")都有一个 devel
分支:
$ git branch -a
* master
remotes/origin/HEAD -> origin/master
remotes/origin/devel
remotes/origin/master
remotes/upstream2/devel
remotes/upstream2/master
如果我只是尝试 git checkout devel
我得到:
$ git checkout devel
error: pathspec 'devel' did not match any file(s) known to git.
我需要说清楚:
$ git checkout -b devel remotes/upstream2/devel
Branch devel set up to track remote branch devel from upstream2 by rebasing.
Switched to a new branch 'devel'
将此与我只有一个遥控器的情况进行比较:
$ git branch -a
* master
remotes/origin/HEAD -> origin/master
remotes/origin/devel
remotes/origin/master
然后:
$ git checkout devel
Branch devel set up to track remote branch devel from origin by rebasing.
Switched to a new branch 'devel'