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 ...
随机推荐
- 数据库bcp导入导出批处理工具
应公司策划要求,需要一个数据库按表导入导出的工具配合svn来进行差异匹配,方便策划每天对数据库修改的记录工具,我使用bcp命令实现如下批处理工具,中间踩了不少坑,现保存在这边希望可以帮到需要此工具的同 ...
- MySQL 如何删除有外键约束的表数据
今天删除数据库中数据,提示因为设置了foreign key,无法修改删除 可以通过设置FOREIGN_KEY_CHECKS变量来避免这种情况. SET FOREIGN_KEY_CHECKS=0; 删除 ...
- html+css小总结
html+css小总结 1.块级元素 <div> <h1> <hr /> <p> <pre> <ol> <ul> & ...
- Python中如何获取类属性的列表
这篇文章主要给大家介绍了在Python中如何获取类属性的列表,文中通过示例代码介绍的很详细,相信对大家的学习或者工作具有一定的参考借鉴价值,有需要的朋友可以参考借鉴,下面来一起看看吧. 前言 最近工作 ...
- OS-96
print('os.access(path,mode):检验权限模式----------------------------------------------------------------') ...
- Sublime text 3搭建Python-Anaconda开发环境
网络上的教程各种各样,大同小异.自己安装时还是出了些问题,因此总结一篇博文. Sublime Text 是一款轻量级跨平台的文本编辑器,可通过包(Package)扩充自身功能. 有很多搭建python ...
- docker命令及操作
docker pull 镜像名字 dockers images docker image ls docker image rm 镜像名/镜像ID docker ps docker ps -a dock ...
- Impala与Hive的比较
1. Impala架构 Impala是Cloudera在受到Google的Dremel启发下开发的实时交互SQL大数据查询工具,Impala没有再使用缓慢的Hive+MapReduce批 ...
- Hive 常用函数汇总
Hive内部提供了很多函数给开发者使用,包括数学函数,类型转换函数,条件函数,字符函数,聚合函数,表生成函数等等,这些函数都统称为内置函数. 目录 数学函数 集合函数 类型转换函数 日期函数 条件函数 ...
- Linux基础命令---dump
dump 检查ext2/3/4文件系统,确定哪些文件需要备份,这些需要备份的文件将会被复制到指定的磁盘或者其他存储介质.dump检查Ext 2/3/4文件系统上的文件,并确定哪些文件需要备份.这些文件 ...