git 如何签出远程分支git?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/40199711/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to checkout remote branch git?
提问by Drop Shadow
Me and my team member are working on same repository. Someone create a branch from master called test_01, worked on that and commit, push to test_01 and merge to master. In the meantime some commit are done in master. Now I want to checkout that test_01 so that I write
我和我的团队成员正在处理同一个存储库。有人从 master 创建了一个名为 test_01 的分支,处理并提交,推送到 test_01 并合并到 master。与此同时,一些提交是在 master 中完成的。现在我想签出 test_01 以便我写
git checkout test_01
and got a git error : pathspec 'test_01' did not match any file know to git .
并得到一个 git 错误:pathspec 'test_01' 与 git 已知的任何文件都不匹配。
回答by VonC
After a git fetch, check the list of the remote tracking branches with:
在 git fetch 之后,使用以下命令检查远程跟踪分支的列表:
git branch -avv
If you see origin/test_01
, a git checkout test_01
should work, since it is the equivalent of:
如果你看到origin/test_01
, agit checkout test_01
应该可以工作,因为它相当于:
git checkout -b <branch> --track <remote>/<branch>
But since it does not work, it is likely the test_01
branch was merged to master
locally by the other developer, and only master was pushed.
You can try and look for the commit of that unnamed branch merged into master: see "Find merge commit which include a specific commit".
但由于它不起作用,很可能test_01
是master
其他开发人员将分支合并到本地,并且只推送了master。
您可以尝试查找合并到 master 的未命名分支的提交:请参阅“查找包含特定提交的合并提交”。