Search code examples
gitgit-merge

Move both branch tips when merging


Is there an easy way to move both branch tips to the merge commit?

Initial situation:

A--B <-- master
 \
  C  <-- dev

Situation after

git checkout master
git merge dev

assuming merge commit D is created without conflicts:

A--B--D <-- master
 \  /
  C  <-- dev

Desired situation:

A--B--D <-- master, dev
 \  /
  C 

Solution

  • Simply merge master into dev :

    git checkout dev
    git merge master
    

    If you want to be extra sure that no extra manual operation got in the way, add the --ff-only option :

    git merge --ff-only master
    

    This option will make sure dev will not create an extra merge commit on top of master, only a fast forward to master will be accepted.