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