0

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?

Kausheel
  • 245
  • 1
  • 2
  • 8
  • Why do you need to merge onto your local master? Why not make the pull request with your feature branch? – vguzmanp Apr 14 '15 at 14:09
  • I did make the PR with a feature branch. However, to use the code for my app, I can't just "git checkout" the feature branch, because other branches have code I need as well. The master branch is the only one with all the features merged in, so this is the branch I need to checkout for my application. – Kausheel Apr 15 '15 at 04:01

1 Answers1

1

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

Your status. Feature merged in upstream and master

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

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

Double merge

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

Merge only in upstream

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.

Only one merge in master!

vguzmanp
  • 785
  • 1
  • 10
  • 31