git 将远程分支拉入不同名称的本地仓库?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12043236/
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
Pull remote branch into local repo with different name?
提问by Cosmin Atanasiu
Alright I did a little bit of research on this but I couldn't find an exact answer, so I have to ask.
好吧,我对此做了一些研究,但我找不到确切的答案,所以我不得不问。
I have 2 remotes: origin and repo2.
我有 2 个遥控器:origin 和 repo2。
I'd like to do something like
我想做类似的事情
git pull repo2 master
But this would pull the master branch of the repo2 into my master. Can I specify a different branch to pull into, for my local branch ?
但这会将 repo2 的 master 分支拉入我的 master 分支。我可以为我的本地分支指定一个不同的分支吗?
回答by KingCrunch
git checkout -b myBranchName repo2/master
回答by Ben Hymanson
The git pull
command is a convenience function that does git fetch
and git merge
. If you only want retrieve branches from a new remote without trying to merge it into any working copy branch you can just use git fetch
. You can then refer to git branch -av
to see all the local and remote branches and operate on either remote as you like.
该git pull
命令是一个方便的函数,它执行git fetch
和git merge
。如果您只想从新远程检索分支而不尝试将其合并到任何工作副本分支中,您可以使用git fetch
. 然后,您可以参考git branch -av
查看所有本地和远程分支,并根据需要在任一远程分支上进行操作。