Git: How do I sync my local and upstream repositories without duplicate PR merge commits?

最后都变了- 提交于 2019-12-13 07:35:32

问题


I need to merge my own pull request feature branch onto my local repo's master branch. However, if the upstream maintainer merges my pull request, I'll have to pull in another merge commit. Git doesn't realize that I already merged the same branch before, so instead I have 2 merge commits for the same branch.

How do you guys sync your local and upstream repositories without duplicate merge commits?


回答1:


If I understand you correctly, your status is more or less this:

(Black = upstream, blue = feature, green = master)

So, when you merge upstream into master, you get this:

You need a local integration branch and an upstream-synced branch. You use the local integration branch to merge your features (what you are doing in master right now). And you use the upstream to keep track of upstream merges.

When you make a PR and it's accepted upstream, you receive it as a merge in your upstream branch, while you local integration branch (master in this case) is not merged with the feature branch

After that you can merge upstream safely in master, and you get one merge in master. Or if you really don't want any merges, you can use rebase.



来源:https://stackoverflow.com/questions/29625397/git-how-do-i-sync-my-local-and-upstream-repositories-without-duplicate-pr-merge

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!