How do I update a GitHub forked repository?
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
Open Terminal.
Change the current working directory to your local project.
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?的更多相关文章
- git如何merge github forked repository里的代码更新?(转)
参考内容:git如何merge github forked repository里的代码更新? [refer to ]http://www.haojii.com/2011/08/how-to-git- ...
- git如何merge github forked repository里的代码更新
git如何merge github forked repository里的代码更新? 问题是这样的,github里有个项目ruby-gmail,我需要从fork自同一个项目的另一个repository ...
- Github 删除 repository
Github 删除 repository 如下图操作
- 在Jenkins中获取GitHub对应Repository的Resource Code
1):Install Jenkins 请看如下链接: https://wiki.jenkins-ci.org/display/JENKINS/Installing+Jenkins 2):Install ...
- github import repository创建github仓库
现在,假设我们从零开发,那么最好的方式是先创建远程库,然后,从远程库克隆. 首先,登陆GitHub,创建一个新的仓库,名字叫blog: 1.先创建一个项目仓库 2. 我们勾选Initialize th ...
- 如何在Github创建repository
第一步:登陆Github,点击new repository 第二步:输入相应内容创建 第三步,创建完成,如下.
- 如何用Github删除repository
第一步,登陆github,一定要点开要删除的repository,再选择相应的setting: 第二步,下拉选择,delete this repository 第三步,输入删除的仓库名,删除repos ...
- GitHub的repository的相关操作
原文地址 https://www.jianshu.com/p/038e8ba10e45 1.准备工作 a.有自己的GitHub账号(https://github.com/)b.在自己本地有安装git软 ...
- 使用GitHub管理Repository
对已有的Repository进行修改 将已有的项目克隆到本地 git clone https://github.com/username/project-name 或者同步已经下载的项目 git pu ...
随机推荐
- Agreementhasbeenupdated--EditPhoneNumber
1.https://appleid.apple.com/#!&page=signin 登录appid账号 在账户里面的编辑 添加更多信息,新增手机号 2.如果不可以 可以试下这个https: ...
- Linux发展历史图
Linux发展历史图 http://futurist.se/gldt/wp-content/uploads/12.10/gldt1210.svg
- css 常用的属性
box-shadow: 10px 10px 5px #000000; //给元素添加阴影 使用伪元素after要注意加上content属性 例如:.log:after{ content:" ...
- Flask中'endpoint'(端点)的理解
翻译整理自Stack Overflow:http://stackoverflow.com/questions/19261833/what-is-an-endpoint-in-flask 原文中用到了m ...
- sklearn_Logistic Regression
一.什么是逻辑回归? 一种名为“回归”的线性分类器,其本质是由线性回归变化而来的,一种广泛使用于分类问题中的广义回归算法 面试高危问题:Sigmoid函数的公式和性质 Sigmoid函数是一个S型的函 ...
- [How to] ROOT, Backup & Flash (MTKDroidTools, Spflashtool, CWM)
这是一篇来自xda论坛的文章,写得很详细,很有用,以下是原文: Hi This is a guide to ROOT, backup and flash your MTK65xx or Other d ...
- 7zip
1.下载地址. https://www.7-zip.org/ 2.傻瓜式安装.
- 004-ubuntu安装配置SSH服务
一.ssh安装. 1.# sudo apt-get -y install openssh-server. 2.在/etc/ssh/sshd_config文件中添加一句:PermitRootLogin ...
- 论文笔记:语音情感识别(三)手工特征+CRNN
一:Emotion Recognition from Human Speech Using Temporal Information and Deep Learning(2018 InterSpeec ...
- mysql索引使用策略及优化
原文地址:http://blog.codinglabs.org/articles/theory-of-mysql-index.html 索引使用策略及优化 MySQL的优化主要分为结构优化(Schem ...