Git Flow

Using git flow -- or not

Feature Branches

All feature development done here.

$ git checkout -b my-feature develop

Adding new features to develop

When the new feature is complete, checkout develop.

$ git checkout develop

Merge feature branch into development branch.

$ git merge --no-ff myfeature

Update remote development branch.

$ git push origin develop

Release Branches

$ git checkout -b release-1.2 develop
$ subl README.md

Update the version and detail the changes as much as you can in the README file.

Bug fixes can happen here, but no features or anything

$ git commit -am "Bumped version number to 1.2"

When this is ready to be released:

$ git checkout main
$ git merge --no-ff release-1.2

Tag it.

$ git tag -a 1.2 -am "message"

and we need to merge this back into develop ... might result in conflicts so just fix and commit

$ git checkout develop
$ git merge --no-ff release-1.2

Now we are really done so let's get rid of it:

$ git branch -d release-1.2

Update the remote:

$ git push origin main
$ git push origin develop
$ git push --tags

Hotfix Branches

$ git checkout -b hotfix-1.2.1 main

Update the README file with just the new version number (unless this is going to be a quick change and you know what the fix is and can fill in details.)

$ git commit -a -m "Bumped version number to 1.2.1"

Fix bug and commit the fix in one or more commits. Don't forget to fill in details for the README!

$ git commit -m "Fixed severe production problem"

Commit to main, tag it and commit to develop:

$ git checkout main
$ git merge --no-ff hotfix-1.2.1
$ git tag -a 1.2.1 -am "message"
$ git checkout develop
$ git merge --no-ff hotfix-1.2.1

Delete the branch now that we're done with it.

$ git branch -d hotfix-1.2.1

update the remote.

$ git push origin main
$ git push origin develop
$ git push --tags

Exceptions

The one exception to the rule here is that, when a release branch currently exists, the hotfix changes need to be merged into that release branch, instead of develop. Back-merging the bugfix into the release branch will eventually result in the bugfix being merged into develop too, when the release branch is finished. (If work in develop immediately requires this bugfix and cannot wait for the release branch to be finished, you may safely merge the bugfix into develop now already as well.)