且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何将fork与原始GitHub项目同步?

更新时间:2022-06-20 09:04:57

您无需再次refork.只需添加一个远程服务器(例如upstream)和fetch upstream即可更新克隆的存储库.

You don't need to refork again. Just add a remote (say, upstream) and fetch upstream to update your cloned repository.

$ git remote add upstream <original-repo-url>
$ git fetch upstream                 # update local with upstream

$ git diff HEAD..upstream/master     # see diffs between local and upstream/master (if there is no diff then both are in sync)

$ git pull upstream master           # pull upstream's master into local branch
$ git push origin HEAD               # push to your forked repo's remote branch