Workflow guidelines:
master
branch is always production-ready, deployable, 100% green test suite- New development is done on feature branches, with frequent rebasing onto master
- Clean commit history by preferring to rebase instead of merge (
git pull
is configured to automatically rebase)
Workflow
- Pull the latest from
origin/master
:
12git pull origin master - Create your feature branch
12git checkout -b concise-feature-branch-name - Begin work on the new feature
- Keep your feature branch updated with master by rebasing onto master:
123git fetch origin mastergit rebase origin/master
or
12345git checkout mastergit pullgit checkout concise-feature-branch-namegit rebase master
Resolve any conflicts that occur during rebase. - Push your branch remotely and create a pull request when ready for peer review:
12git push -u origin concise-feature-branch-name
Depending on peer review, keep pushing changes to the remote as needed. - Interactively rebase your feature branch onto master once the feature is approved and ready for production:
12git rebase -i origin/master - Merge into
master
:
123456789git checkout mastergit pull origin master# The --no-ff is optional here...see the notes belowgit merge --no-ff concise-feature-branch-namegit push origin master# This is also a good time to create a release taggit tag 1.0.10git push 1.0.10 - Remove all branches that have been merged into master:
123git branch -d concise-feature-branch-namegit push origin :concise-feature-branch-name
Notes
- Git config for rebasing by default:
123git config --global branch.autosetuprebase alwaysgit config --global pull.rebase true - Merging into master in step 7 with the –no-ff option will create a merge commit even if the merge could be a fast-forward. Having this merge commit is helpful in that it retains the commits that went into the feature branch. (If you don’t care to keep this series of commits on a feature branch or the feature branch was a single commit, you can omit the
--no-ff
in the merge command and let it fast-foward.) Single-level merge bubbles like this are ok. Here’s what we don’t want:
credits: https://gist.github.com/leesmith/8441773#workflow-guidelines
Thanks, great article.