Skip to content

Release: Merging Development branch back into Main branch

Myckel Habets edited this page Aug 7, 2016 · 1 revision

Based on https://wiki.magnolia-cms.com/display/DEV/Git%3A+merging+a+development+branch+into+master with some extra comments.

Prerequisites

local master is up-to-date

Steps

First create an integration branch out of your development branch

git checkout -b development-int
  • This guarantees that you won't spoil your development branch
  • This is especially valid for dev branches that are also remote, we should never rewrite the history of a shared branch

Then rebase that new branch onto master

git rebase -i master development-int

Publish that integration branch, so this can be used for reviews

git push -u origin development-int

Now all your commits are stacked on top of the latest master, therefore merging to master should be a fast-forward. We want to enforce this.

git checkout master
git merge development-int --ff-only
  • This will reject non fast-forward merges

Finally if you have to pull again from master before pushing, don't forget to do a pull rebase.

git pull --rebase

Delete your integration branch

git branch -d development-int

If you pushed it, then delete the remote branch too:

git push origin --delete development-int

Don't forget to push the rebase to github:

git push

Result

Your branch commits are flattened into master's history You can keep working on your dev branch

  • remote tracking is not spoiled by the rebase
  • then reapply the same pattern for the next merge to master
Clone this wiki locally