更新分叉的GitHub回购以匹配原始的最新代码和提交 [英] Updating forked GitHub repo to match original's latest code and commits

查看:150
本文介绍了更新分叉的GitHub回购以匹配原始的最新代码和提交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我前几天分叉了一个GitHub项目,并从它的问题中看出,主分支自此以后进行了一些修改。

当我 cd 到我的该项目的位置目录并使用 git pull code>,它说,已经是最新的。为什么?



如何更新我的分支以包含来自原始分录的提交? div>

当您分配一个存储库时,原始存储库的一个副本将在您的GitHub帐户上建立。这允许对复制进行读写访问。



当原始存储库资源具有可以使您的副本受益的提交时,请按照以下步骤更新您的fork主分支。您可以更新其他分支,但典型的工作流程是将 master 更新为原始存储库。


  1. 打开终端

  2. cd 到您的项目目录c> git remote add upstream<原始版本库>

  3. git分支和验证您是否位于 master 分支

  4. git pull --rebase upstream master

第5步将获取原始存储库的所有新提交,将它们应用于 master code>分支从最后一个 merge-base ,然后将所有分支的提交包括在最上面。



无论何时您需要再次更新叉子,只需在第5步中运行该命令即可。


I forked a GitHub project several days ago and from its issues, I can see that the master branch has had some modifications since.

When I cd to my location directory of this project and use git pull, it says, "Already up-to-date". Why?

How do I update my fork to include the commits from the original repo?

解决方案

When you fork a repository, a copy of the original repository is established on your GitHub account. This permits read+write access to the "copy".

When the original repository resource has commits that would benefit your copy, follow these steps to update your fork's master branch. You could update other branches, but typical workflow is to update master against the original repository.

  1. Open a Terminal
  2. cd to your project directory
  3. git remote add upstream <url-of-original-repository>
  4. git branch and verify you are on master branch
  5. git pull --rebase upstream master

Step #5 will fetch all new commits of the "original" repository, apply them to master branch from the last merge-base, then include all of your branch's commits "on top".

Any time you need to update your fork again, simply run the command in step #5.

这篇关于更新分叉的GitHub回购以匹配原始的最新代码和提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆