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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 13:05:24  来源:igfitidea点击:

Git pull from specific branch

gitpull

提问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 pullis the same as git fetchfollowed by git merge.

git pullgit fetch后面的相同git merge

To create a local branch tracking a branch on a remote, first fetch from the remote and then run git checkoutwith 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 instance origin.
  • <branch>is the name of a branch on that remote. If git branch -rshows a branch name remotes/origin/foo, Git should set this up correctly if you do git checkout foo.
  • <remote>是遥控器的名称,例如origin
  • <branch>是那个遥控器上的一个分支的名称。如果git branch -r显示分支名称remotes/origin/foo,则 Git 应该正确设置它git checkout foo