- Never work on the
master
branch. Create a feature branch, work there, then merge intomaster
. - Try to keep feature braches short-lived, or at least keep them up to date with
master
. This can save you a lot of headaches when merging intomaster
. - When merging feature branches:
- Announce what you're doing on the Slack channel. This is to avoid race conditions where multiple people are attempting to rebase and merge at the same time.
- Pull changes to the master branch from the central repository.
- Clean up your feature branch and update it with changes from
master
. Two ways of doing this:- Rebasing
feature
ontomaster
:git checkout feature && git rebase -i master
(give this article a read if you're unfamiliar with the golden rule of rebasing!). - Merging
master
intofeature
:git checkout feature && git merge master
. This has the upside of being safer if you're unsure about rebasing, but creates a messier history.
- Rebasing
- Check the resulting codebase to make sure nothing is broken.
- Merge
feature
intomaster
; at this point it should be a simple fast-forward commit with no conflicts to resolve:git checkout master && git merge feature
.