FORK了别人的项目之后如何保持同步更新

你 fork 了别人的项目之后,他更新了代码,你 fork 的项目如何与原项目同步更新?

远程仓库执行 fork 操作,得到自己的 url

git clone url 到本地

配置远程分支:git remote add upstream [fork项目的地址]

运行 git remote -v,会出现:

origin https://gitee.com/phpzhi/testPro.git (fetch)
origin https://gitee.com/phpzhi/testPro.git (push)
upstream https://gitee.com/opan/testPro.git (fetch)
upstream https://gitee.com/opan/testPro.git (push)

执行 git fetch upstream 拉取远程仓库的代码

合并拉取的代码 git merge upstream/master

上传 git push

posted @ 2021-12-07 16:36  奔跑中的wiggins  阅读(915)  评论(0编辑  收藏  举报