3

So I fork a repo, the repo then has new commits. I update my fork with git fetch upstream and git merge upstream/master. Now lets say I make a change after this and submit a pull request. Those previously merged commits appear in the pull request. How do I not make this happen? I'm tired of having to delete the fork and re-fork so that my pull requests are clean.

1 Answers1

0

If you don't want having merge commits, try git rebase. It wipes all you work and reapplies all you changes ahead. But note that your commits will become different.

amaslenn
  • 797
  • 9
  • 16
  • If this is the taken approach, I think the `git pull upstream/master --rebase` could be used in place of the fetch/merge no? – BlackVegetable Feb 26 '14 at 18:19
  • I want my fork to remain in sync with the repo. I'm not making changes for itself, just for pull requests. – The Immortal Feb 26 '14 at 18:21
  • Sorry if I misunderstand you. But `rebase` will help you to keep you fork up to date and also avoid merge commits. @BlackVegetable already mentioned exact command. – amaslenn Feb 26 '14 at 18:26
  • Also, it's not only merge commits. Here's another example: my pull request is accepted. If I sync my fork, when I make a commit and submit a pull request, the previous commits from the previous pull request appear in the pull request in addition to my new commit. The only solution I have is deleting the fork and re-forking, which is pretty annoying. – The Immortal Feb 26 '14 at 18:27
  • And `rebase` will help you in this situation :) It keeps your history linear. Just give it a try. – amaslenn Feb 26 '14 at 18:32
  • I tried it and have the same problem. Any commits to the repo from after I forked appear in my pull request. No merge commits. – The Immortal Feb 26 '14 at 18:43