When git rebasing two branches with some shared history, is there an easy way to have the common history remain common?

git rebase –committer-date-is-author-date –preserve-merges –onto A* A C git rebase –committer-date-is-author-date –preserve-merges –onto A* A B This should keep the common commits having the same sha1 and any merges preserved. Preserve merges is not required in this case, but will become an issue with a less trivial history. To do this for all branches that … Read more

git rebase basics

Let’s start from the beginning. Here’s a diagram of your original state: A-B-C (master, origin/master) \ D-E-F-G-H-I (next, origin/next) When you checked out next and rebased next onto origin/master, it created 6 new commits after the two that are already on origin/master. These new commits have “master commit #2” (C in my diagram) as their … Read more

How to rebase local branch onto remote master

First fetch the new master from the upstream repository, then rebase your work branch on that: git fetch origin # Updates origin/master git rebase origin/master # Rebases current branch onto origin/master Update: Please see Paul Draper’s answer for a more concise way to do the same – recent Git versions provide a simpler way to … Read more