I recently forked a project and applied several fixes. I then created a pull request which was then accepted.

A few days later another change was made by another contributor. So my fork doesn't contain that change.

How can I get that change into my fork? Do I need to delete and re-create my fork when I have further changes to contribute? Or is there an update button?

~~~~~~~~~~~~~

In your local clone of your forked repository, you can add the original GitHub repository as a "remote". ("Remotes" are like nicknames for the URLs of repositories - origin is one, for example.) Then you can fetch all the branches from that upstream repository, and rebase your work to continue working on the upstream version. In terms of commands that might look like:

# Add the remote, call it "upstream":

git remote add upstream https://github.com/whoever/whatever.git

# Fetch all the branches of that remote into remote-tracking branches,
# such as upstream/master: git fetch upstream # Make sure that you're on your master branch: git checkout master # Rewrite your master branch so that any commits of yours that
# aren't already in upstream/master are replayed on top of that
# other branch: git rebase upstream/master

If you don't want to rewrite the history of your master branch, (for example because other people may have cloned it) then you should replace the last command with git merge upstream/master. However, for making further pull requests that are as clean as possible, it's probably better to rebase.

If you've rebased your branch onto upstream/master you may need to force the push in order to push it to your own forked repository on GitHub. You'd do that with:

git push -f origin master

You only need to use the -f the first time after you've rebased.

As your fork only exists on github, and github does not have tools for doing merges through the web interface, then the right answer is to do the upstream merge locally and push the changes back to your fork. –

Syncing a fork

  1. Open Terminal.

  2. Change the current working directory to your local project.

  3. Fetch the branches and their respective commits from the upstream repository. Commits to master will be stored in a local branch, upstream/master.

git fetch upstream
remote: Counting objects: , done.
remote: Compressing objects: % (/), done.
remote: Total (delta ), reused (delta )
Unpacking objects: % (/), done.
From https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY
* [new branch] master -> upstream/master

4.Check out your fork's local master branch.

git checkout master
Switched to branch 'master'

5.Merge the changes from upstream/master into your local master branch. This brings your fork's master branch into sync with the upstream repository, without losing your local changes.

git merge upstream/master
Updating a422352..5fdff0f
Fast-forward
README | -------
README.md | ++++++
files changed, insertions(+), deletions(-)
delete mode README
create mode README.md

If your local branch didn't have any unique commits, Git will instead perform a "fast-forward":

git merge upstream/master
Updating 34e91da..16c56ad
Fast-forward
README.md | +++--
file changed, insertions(+), deletions(-)

How do I update a GitHub forked repository?的更多相关文章

  1. git如何merge github forked repository里的代码更新?(转)

    参考内容:git如何merge github forked repository里的代码更新? [refer to ]http://www.haojii.com/2011/08/how-to-git- ...

  2. git如何merge github forked repository里的代码更新

    git如何merge github forked repository里的代码更新? 问题是这样的,github里有个项目ruby-gmail,我需要从fork自同一个项目的另一个repository ...

  3. Github 删除 repository

    Github 删除 repository 如下图操作

  4. 在Jenkins中获取GitHub对应Repository的Resource Code

    1):Install Jenkins 请看如下链接: https://wiki.jenkins-ci.org/display/JENKINS/Installing+Jenkins 2):Install ...

  5. github import repository创建github仓库

    现在,假设我们从零开发,那么最好的方式是先创建远程库,然后,从远程库克隆. 首先,登陆GitHub,创建一个新的仓库,名字叫blog: 1.先创建一个项目仓库 2. 我们勾选Initialize th ...

  6. 如何在Github创建repository

    第一步:登陆Github,点击new repository 第二步:输入相应内容创建 第三步,创建完成,如下.

  7. 如何用Github删除repository

    第一步,登陆github,一定要点开要删除的repository,再选择相应的setting: 第二步,下拉选择,delete this repository 第三步,输入删除的仓库名,删除repos ...

  8. GitHub的repository的相关操作

    原文地址 https://www.jianshu.com/p/038e8ba10e45 1.准备工作 a.有自己的GitHub账号(https://github.com/)b.在自己本地有安装git软 ...

  9. 使用GitHub管理Repository

    对已有的Repository进行修改 将已有的项目克隆到本地 git clone https://github.com/username/project-name 或者同步已经下载的项目 git pu ...

随机推荐

  1. CCO2017 Vera and Trail Building 构造+图论

    正解:构造+图论 解题报告: 找了半天才找到的传送门! 先简要表达下题意 一个图上,如果存在(a,b)满足a<b且存在从a到b再回到a的路径,每条道路被经过至多一次,我们称(a,b)为完美点对试 ...

  2. 洛谷P2679 子串 [noip2015] dp

    正解:dp 解题报告: 感觉是道dp好题啊,所以就写了个题解 代码实现难度低,思维难度大,像我这种思维僵化傻逼选手只想到了爆搜+组合数学... 其实是道很妙的dp题!好趴也没有多妙主要大概是妙在想到了 ...

  3. MySQL 如何删除有外键约束的表数据

    今天删除数据库中数据,提示因为设置了foreign key,无法修改删除 可以通过设置FOREIGN_KEY_CHECKS变量来避免这种情况. SET FOREIGN_KEY_CHECKS=0; 删除 ...

  4. MySQL DBA 管理常用命令

    一:在Linux下管理MySQL数据库的时候总有一些很紧急的情况,发现数据库突然变得压力很大了,那么作为一个DBA,也许需要一些常用的手段或者说命令去分析问题出现在哪里,然后解决: 数据库突然产生压力 ...

  5. NSLog打印NSInteger老是有warning

    zSpecifies that a following [...] conversion specifier applies to a size_t or the corresponding sign ...

  6. Math.abs(~2018) —— 入群问答题

    这道题的关键点在于对位操作符“~”的理解,以及内部的具体实现(设计到补码) 最后的结果是:2019 参考文章: http://www.w3school.com.cn/js/pro_js_operato ...

  7. C#方法参数传递-同时使用ref和out关键字

    在方法参数传递中,可以同时使用ref和out关键字,但是要注意ref和out参数传递的不同. using System;class Program{static void Main(){    Pro ...

  8. CoreSight介绍篇

    ARM的嵌入式IDE发展: 1)SDT,英文全称ARM SoftWare Development Kit,是ARM为方便用户在ARM芯片进行应用软件开发而推出的一整套开发工具. 2)ADS,英文全称A ...

  9. Lower Power with CPF(三)

    常用的一些Lower Power的策略: 1)Clock tree optimization and clock gating:在正常情况下clock信号会一直toggle at the maximu ...

  10. zw版【转发·台湾nvp系列Delphi例程】HALCON Roberts2

    zw版[转发·台湾nvp系列Delphi例程]HALCON Roberts2 procedure TForm1.Button1Click(Sender: TObject);var op: HOpera ...