Skip to content

Instantly share code, notes, and snippets.

@miere
Created May 8, 2014 22:40
Show Gist options
  • Save miere/462ec9f736a1ec9e6642 to your computer and use it in GitHub Desktop.
Save miere/462ec9f736a1ec9e6642 to your computer and use it in GitHub Desktop.
A successful Git branching model

A successful Git branching model

A straightforward version from Vincent Driessen article.

Creating a feature branch

Create a copy branch from develop.

$ git checkout -b feature-1 develop

Merge with develop after code your feature.

Switched to a new branch "feature-1"
$ git checkout develop
Switched to branch 'develop'
$ git merge --no-ff feature-1
Updating ea1b82a..05e9557
(Summary of changes)

Delete unneeded branch.

$ git branch -d feature-1
Deleted branch feature-1 (was 05e9557).
$ git push origin develop

Creating a release branch

$ git checkout -b release-1.2 develop
Switched to a new branch "release-1.2"

Change your artifacts version. Maven developers could use this step to change its pom.xml's versions.

$ git commit -a -m "Bumped version number to 1.2"
[release-1.2 74d9424] Bumped version number to 1.2
1 files changed, 1 insertions(+), 1 deletions(-)

This new branch may exist there for a while, allowing the team to fix some remaining bug found during release tests. The finish your release:

$ git checkout master
Switched to branch 'master'
$ git merge --no-ff release-1.2
Merge made by recursive.
(Summary of changes)
$ git tag -a 1.2

Merge the release with develop if you commit something in your release branch.

$ git checkout develop
Switched to branch 'develop'
$ git merge --no-ff release-1.2
Merge made by recursive.
(Summary of changes)

The delete unneeded branch

$ git branch -d release-1.2
Deleted branch release-1.2 (was ff452fe).

Hotfix

$ git checkout -b hotfix-1.2.1 master
Switched to a new branch "hotfix-1.2.1"

Change your artifacts version.

$ git commit -a -m "Bumped version number to 1.2.1"
[hotfix-1.2.1 41e61bb] Bumped version number to 1.2.1
1 files changed, 1 insertions(+), 1 deletions(-)

Apply some fixes on your code, then:

$ git commit -m "Fixed severe production problem"
[hotfix-1.2.1 abbe5d6] Fixed severe production problem
5 files changed, 32 insertions(+), 17 deletions(-)

Apply the fix on master

$ git checkout master
Switched to branch 'master'
$ git merge --no-ff hotfix-1.2.1
Merge made by recursive.
(Summary of changes)
$ git tag -a 1.2.1

Apply the same fix on develop

$ git checkout develop
Switched to branch 'develop'
$ git merge --no-ff hotfix-1.2.1
Merge made by recursive.
(Summary of changes)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment