Git:从其他远程拉取

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2257196/
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-10 07:51:11  来源:igfitidea点击:

Git: Pull from other remote

gitgithub

提问by Ran

I have created a fork from a project on GitHub. How can I now pull changes from the project that I forked from?

我从 GitHub 上的一个项目创建了一个分支。我现在如何从我分叉的项目中提取更改?

回答by Igor Zevaka

git pullis really just a shorthand for git pull <remote> <branchname>, in most cases it's equivalent to git pull origin master. You will need to add another remote and pull explicitly from it. This page describes it in detail:

git pull实际上只是 的简写git pull <remote> <branchname>,在大多数情况下它相当于git pull origin master。您将需要添加另一个遥控器并从中明确拉出。本页对其进行了详细描述:

http://help.github.com/forking/

http://help.github.com/forking/

回答by Ran

upstreamin the github example is just the name they've chosen to refer to that repository. You may choose any that you like when using git remote add. Depending on what you select for this name, your git pullusage will change. For example, if you use:

upstream在 github 示例中只是他们选择引用该存储库的名称。使用时您可以选择任何您喜欢的git remote add。根据您为此名称选择的内容,您的git pull用法会发生变化。例如,如果您使用:

git remote add upstream git://github.com/somename/original-project.git

git remote add upstream git://github.com/somename/original-project.git

then you would use this to pull changes:

那么您将使用它来拉取更改:

git pull upstream master

git pull upstream master

But, if you choose origin for the name of the remote repo, your commands would be:

但是,如果您选择 origin 作为远程仓库的名称,您的命令将是:

To name the remote repo in your local config: git remote add origin git://github.com/somename/original-project.git

在本地配置中命名远程仓库: git remote add origin git://github.com/somename/original-project.git

And to pull: git pull origin master

并拉: git pull origin master