Fork后,如何在Gitlab和Github下如何同步源的新更新

例子

问题

我在自己的vekko/RuoYi库改啊改,某一天源库y_project/RuoYi更新了,我怎么同步源库过来?

1、配置上游项目地址

进入自己本地库中通过git remote -v 查看源信息

G:vekko_cc_projectsRuoYi>git remote -v
origin  https://gitee.com/vekko/RuoYi.git (fetch)
origin  https://gitee.com/vekko/RuoYi.git (push)

fetch 和push 都是自己的源,所有我们要添加repo的源

添加上游repo源

G:vekko_cc_projectsRuoYi>git remote add upstream https://gitee.com/y_project/RuoYi.git

注:删除为git remote remove upstream

然后再看一下源信息,可以看到上游源已经添加进来了

G:vekko_cc_projectsRuoYi>git remote -v
origin  https://gitee.com/vekko/RuoYi.git (fetch)
origin  https://gitee.com/vekko/RuoYi.git (push)
upstream        https://gitee.com/y_project/RuoYi.git (fetch)
upstream        https://gitee.com/y_project/RuoYi.git (push)

2、获取上游源项目更新。使用fetch命令,fetch之后会被存储到本地一个分支。

G:vekko_cc_projectsRuoYi>git fetch upstream
From https://gitee.com/y_project/RuoYi
* [new branch]        master     -> upstream/master

3、合并到本地分支。切换到 master 分支,合并 upstream/master 分支。

G:vekko_cc_projectsRuoYi>git merge upstream/master
Already up to date.

4、提交推送。根据自己情况提交推送自己项目的代码。

git push origin master
原文地址:https://www.cnblogs.com/lofish/p/12681333.html