github fork别人项目后,如何保持跟原来的git仓库同步.md

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/sun_ashe/article/details/82767538

在做MySQL相关的工作时,我需要fork mysql-server的项目,然后在某一个版本上新建自己的分支。但是,mysql-server依然在不停的发布新的代码,应该如何同步这些新发布的代码呢?可以通过如下的方法

首先要先确定一下是否建立了主repo的远程源:

ashe@macos /data/mysql-server ((HEAD detached at mysql-5.7.23)) $ git remote -v
origin	https://github.com/sunashe/mysql-server.git (fetch)
origin	https://github.com/sunashe/mysql-server.git (push)

如果里面只能看到你自己的两个源(fetch 和 push),那就需要添加主repo的源:

ashe@macos /data/mysql-server ((HEAD detached at mysql-5.7.23)) $ git remote add upstream https://github.com/mysql/mysql-server
ashe@macos /data/mysql-server ((HEAD detached at mysql-5.7.23)) $ git remote -v
origin	https://github.com/sunashe/mysql-server.git (fetch)
origin	https://github.com/sunashe/mysql-server.git (push)
upstream	https://github.com/mysql/mysql-server (fetch)
upstream	https://github.com/mysql/mysql-server (push)

然后你就能看到upstream了。
拉取upstream后续更新代码

git fetch upstream

猜你喜欢

转载自blog.csdn.net/sun_ashe/article/details/82767538