git checkout -b myfeature-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
git rebase -i master myfeature-int
- Ideally you do an interactive rebase with the -i flag, so that you can squash, reorder, or drop commits
- 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.
git push -u origin myfeature-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 mastergit merge myfeature-int --ff-only- This will reject non fast-forward merges
git pull --rebase
git branch -d myfeature-int- If you pushed it, then delete the remote branch too:
git push origin --delete myfeature-int
Stolen from https://wiki.magnolia-cms.com/display/DEV/Git%3A+merging+a+development+branch+into+master