问题
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