git 更新我从另一个项目分叉出来的 github repo

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

Update my github repo which is forked out from another project

gitgithub

提问by zengr

I have forked out a Parent: projectto Child: this. Now, I want to update my child with parents current updates. Can I do that, if yes how?

我已经分出一个 Parent:项目给 Child: this。现在,我想用父母当前的更新来更新我的孩子。我可以这样做吗,如果可以,怎么做?

When I update my github repo, then I can do a "git pull" to update my local repo.

当我更新我的 github 存储库时,我可以执行“git pull”来更新我的本地存储库。

回答by Cascabel

In your local clone of Child, pull from Parent, adding it as a remote if you like:

在您本地的 Child 克隆中,从 Parent 拉取,如果您愿意,可以将其添加为远程:

cd child
git remote add parent <parent-url>
git pull parent

The url of the parent could be the public github repo, or your local clone of it - the local clone will of course be faster. If you want to pull a branch other than the current HEAD of the parent repo, just add an argument (e.g. git pull parent topic-branch). If this is a one-time thing, you can just skip adding the remote: git pull <parent-url> [branch].

父级的 url 可以是公共 github 存储库,也可以是它的本地克隆 - 本地克隆当然会更快。如果你想拉除父仓库当前 HEAD 之外的分支,只需添加一个参数(例如git pull parent topic-branch)。如果这是一次性的事情,您可以跳过添加遥控器:git pull <parent-url> [branch]

Pulling is a combination of fetching and merging, so once you've done that, you've got a new merge commit you'll presumably want to push back to your public repo at some point.

拉取是获取和合并的组合,所以一旦你完成了这一点,你就有了一个新的合并提交,你可能想在某个时候推回到你的公共仓库。

The key point here, in case it's not clear, is that pulling from the parent (upstream) repository is not different from pulling from your public clone of child, your current repository. Either way, you're fetching from a repository with some common history, and merging that into your current branch. And of course, since you're merging, a work tree is required - so this is something that must be done in your local repo. The repo hosted on github is essentially a way of publishing what you've done locally. All you can really do with it is push/pull, and browse what's there.

如果不清楚,这里的关键点是从父(上游)存储库中拉取与从您当前存储库的子库的公共克隆中拉取没有什么不同。无论哪种方式,您都是从具有一些共同历史记录的存储库中获取,并将其合并到您当前的分支中。当然,由于您正在合并,因此需要一个工作树 - 所以这必须在您的本地存储库中完成。github 上托管的 repo 本质上是一种发布您在本地完成的工作的方式。你真正能用它做的就是推/拉,并浏览那里有什么。

回答by hobbs

  1. Clone your repo to your local machine, if you haven't already: git clone [email protected]:utkarsh2012/voldemort.git
  2. Add the upstream as a new remote: git remote add upstream git://github.com/voldemort/voldemort.git
  3. With your branch checked out, pull the upstream into your branch, which will create a merge between the two sets of changes: git pull upstreamor git pull upstream branch-to-merge. If you're working on an unpushed branch you can also use git fetchand git rebaseto rebase your work without needing a merge.
  1. 将你的 repo 克隆到你的本地机器上,如果你还没有: git clone [email protected]:utkarsh2012/voldemort.git
  2. 将上游添加为新的远程: git remote add upstream git://github.com/voldemort/voldemort.git
  3. 签出您的分支后,将上游拉入您的分支,这将在两组更改之间创建合并:git pull upstreamgit pull upstream branch-to-merge。如果您正在处理未推送的分支,您还可以使用git fetchgit rebase重新调整您的工作,而无需合并。

回答by Luke Francl

You want:

你要:

git pull git://github.com/voldemort/voldemort.git

git pull git://github.com/voldemort/voldemort.git

回答by thSoft

This can also be done simply on GitHub's web interface: issue a Pull Requestbut swap the base repoand head repo. If the pull can be performed automatically, it will be.

这也可以简单地在 GitHub 的 Web 界面上完成:发出Pull Request但交换base repohead repo。如果拉动可以自动执行,那就是。