Git 从特定分支拉取
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/49636441/
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
Git pull from specific branch
提问by user3568043
I want to pull changes from specified branch to my local repository, but I don't wont it to merge with master branch. What is the right way to do that? Do I have to make my own branch and than pull?
我想将更改从指定分支拉到我的本地存储库,但我不希望它与 master 分支合并。这样做的正确方法是什么?我是否必须创建自己的分支而不是拉?
回答by jsageryd
git pull
is the same as git fetch
followed by git merge
.
git pull
与git fetch
后面的相同git merge
。
To create a local branch tracking a branch on a remote, first fetch from the remote and then run git checkout
with the name of a branch that matches that on the remote:
要创建跟踪远程分支的本地分支,首先从远程获取,然后git checkout
使用与远程匹配的分支名称运行:
git fetch <remote>
git checkout <branch>
<remote>
is the name of the remote, for instanceorigin
.<branch>
is the name of a branch on that remote. Ifgit branch -r
shows a branch nameremotes/origin/foo
, Git should set this up correctly if you dogit checkout foo
.
<remote>
是遥控器的名称,例如origin
。<branch>
是那个遥控器上的一个分支的名称。如果git branch -r
显示分支名称remotes/origin/foo
,则 Git 应该正确设置它git checkout foo
。