每当我在远程仓库中创建一个新分支时,我都无法将它放到我的本地仓库中。
我试过了:
git fetch --all
,它实际上更新了远程分支,但它们没有出现 git branch
git branch -r | grep -v '\->' | while read remote; do git branch --track "${remote#origin/}" "$remote"; done
是唯一对我有用的东西,但它抓住了远程曾经拥有的所有分支。在大型项目中,我最终获得了 100 个以上的分支git branch
git branch
只显示您当地的分支机构。指定-r
显示远程分支,或-a
同时显示本地和远程分支。
要检出远程分支的本地副本,请运行git checkout <branch>
where <branch>
is the name of the branch without the remote name prefix.
一个例子:
$ git branch -a
* master
remotes/origin/HEAD -> origin/master
remotes/origin/foo
remotes/origin/master
$ git checkout foo
Branch 'foo' set up to track remote branch 'foo' from 'origin'.
Switched to a new branch 'foo'
$ git branch -a
* foo
master
remotes/origin/HEAD -> origin/master
remotes/origin/foo
remotes/origin/master
$
你可以阅读更多有关在远程分支机构3.5的Git分支-远程分支的临Git的。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句