这不是 Find out which remote branch a local branch is tracking , 如果我有多个 Remote ,我可能在所有 Remote 中都有“主人”。 git branch
返回 master 但我不知道我所在的 master 分支是在 remoteFoo 还是 remoteBar 中。例如,我可能会这样做:
git clone someRepo.git
cd someRepo
git remote add anotherRemote otherremoteURL
然后
git remote
显示someRepo
anotherRemote
我可以做
git checkout -b master someRepo/master
或 git checkout -b master anotherRemote/master
和 git branch
在这两种情况下都会说“主人”。我如何取回第一部分,“someRepo”或“anotherRemote”?你会认为我可以使用
git remote show
但它需要一个参数,即您想要获取信息的 Remote 的名称。$ git remote show origin
fatal: 'origin' does not appear to be a git repository
fatal: The remote end hung up unexpectedly
$ git remote show
someRepo
anotherRemote
与
git branch
我得到了当前情况的指示:$ git branch
hold
* master
old-stuff
refactor
但是
git remote
中没有“*”输出。
最佳答案
您可能想尝试以下这些以查看详细信息。
git remote -v
git remote -v show origin
下面的示例输出:
dmasi@:/var/www/pirate_booty$ git remote -v
origin git@bitbucket.org:dmasi/pirate_booty_calculator.git (fetch)
origin git@bitbucket.org:dmasi/pirate_booty_calculator.git (push)
dmasi@:/var/www/pirate_booty$ git remote -v show origin
* remote origin
Fetch URL: git@bitbucket.org:dmasi/pirate_booty_calculator.git
Push URL: git@bitbucket.org:dmasi/pirate_booty_calculator.git
HEAD branch: master
Remote branch:
master tracked
Local branch configured for 'git pull':
master merges with remote master
Local ref configured for 'git push':
master pushes to master (up to date)
关于git - 找出本地分支正在跟踪哪个远程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12609415/