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

时间:2017-01-09 07:04:33

标签: git github

我创建了一些GitHub项目的fork。然后我创建了新的分支并在该分支内部做了补丁。我将拉取请求发送给作者,然后他应用了我的补丁并稍后添加了一些提交。我如何才能将GitHub上的fork与原始项目同步?我是否要在GitHub上删除我的fork并每次为每个补丁创建一个新的fork?

1 个答案:

答案 0 :(得分:14)

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

$ 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