-
Notifications
You must be signed in to change notification settings - Fork 30
Release: Merging Development branch back into Main branch
Based on https://wiki.magnolia-cms.com/display/DEV/Git%3A+merging+a+development+branch+into+master with some extra comments.
local master is up-to-date
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
- Ideally you do an interactive rebase with the -i flag, so that you can squash, reorder, or drop commits: https://help.github.com/articles/about-git-rebase/
- Having 3 commits for subsequently renaming a class is an ideal candidate for squashing
- Don't hesitate to re-do it several times over. It's easier to, for example, first reorder some commits, make sure they can be re-applied in that order, then do a second rebase to squash'em.
- For fixing problems, these pages might help: https://help.github.com/articles/resolving-a-merge-conflict-from-the-command-line/ and https://help.github.com/articles/resolving-merge-conflicts-after-a-git-rebase/
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
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