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
masterwill 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 ...
随机推荐
- 改革春风吹满地---hdu2036(多边形用差积求面积)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2036 #include<iostream> #include<stdio.h> ...
- Heavy Transportation---poj1797
求(Dijkstra算法,求每条路径上的最小值 的最大值)和青蛙的那题类似: #include<iostream> #include<stdio.h> #include&l ...
- 非极大值抑制(NMS)
非极大值抑制顾名思义就是抑制不是极大值的元素,搜索局部的极大值.这个局部代表的是一个邻域,邻域有两个参数可变,一个是邻域的维数,二是邻域的大小.这里不讨论通用的NMS算法,而是用于在目标检测中提取分数 ...
- Mirror--如何对运行中的镜像端点更换证书
如果使用证书配置镜像时,没有设置证书的时间,则默认证书有效期为一年,当证书快过期时,需要更换证书. 下面代码演示如何对正在运行的镜像更换证书 --=========================== ...
- csrf攻击原理及如何防止csrf攻击
CSRF(Cross-site request forgery)跨站请求伪造,也被称为“One Click Attack”或者Session Riding,是一种对网站的恶意利用,通过伪装来自受信任用 ...
- dedecms手机站图片错误的解决方法
现在手机站(如m.*.com)是网站建设标配,在用dedecms建站也可以实现(不会的话欢迎来骚扰ytkah),手机站一个比较麻烦的事是图片一直显示不出来,为什么呢?程序一般是调用图片的相对地址,比如 ...
- vs2015 相关
VS2015一共有3个版本,Visual Studio Community(社区版).Visual Studio Professional(专业版).Visual Studio Enterprise( ...
- 使用fiddler对手机APP进行抓包
在做手机或移动端APP的接口测试时,需要从开发人员那里获取接口文档,接口文档应该包括完整的功能接口.接口请求方式.接口请求URL.接口请求参数.接口返回参数.如果当前项目没有接口文档,则可以使用fid ...
- 初次使用git上传代码(转)
转自 http://www.cnblogs.com/cxk1995/p/5800196.html 首先你需要一个github账号,所有还没有的话先去注册吧! https://github.com/ 我 ...
- 修改SQL Server 的排序规则(转)
转自http://jimshu.blog.51cto.com/3171847/1095780/ 一.修改SQL Server服务器(实例)的排序规则 以下实验使用了SQL Server 2008 R2 ...