Git Flow is a mainstream process for branch per feature development. Git Flow is the best method I’ve found for managing project developed by small to medium project teams. Before you start reading this post you should read two mandatory lectures:
This blog post is a step by step instruction how to use Git Flow together with Maven build tool, continuous integration server (e.g: Bamboo) and bug tracker (e.g: JIRA). If you are interested in how to automate the whole process, watch this Flow with Bamboo video. But I really recommend to start using Git Flow with pure git commands, when you understand the concept move to Git Flow, and then automate everything eventually.
Start feature branch
- Assign JIRA task to you.
- Move JIRA tasks from “To Do” to “In Progress”.
-
Create feature branch for the JIRA user story (if it’s a first task of the user story). Feature branch must reflect JIRA issue number and have meaningful name, e.g: PROJ-01_user_registration.
1
mvn jgitflow:feature-start
- Verify that:
- New local feature branch feature/PROJ-01_user_registration is created.
-
Optionally push feature branch into remote repository.
1
git push origin feature/PROJ-01_user_registration
- Verify that:
- The feature branch is pushed into remote repository.
- New Bamboo build plan is created for the feature branch.
Checkout the feature branch
-
Checkout the feature branch created by other developer (e.g for code review).
1
git checkout feature/PROJ-01_user_registration
Work on the feature branch
-
Periodically push changes to the remote repository.
1
git push origin feature/PROJ-01_user_registration
-
Verify that:
- Bamboo build plan for feature branch is green.
Finish feature branch
-
Ensure your local develop branch is up to date.
1 2
git checkout develop git pull origin develop
-
To avoid conflicts during finishing feature branch, ensure that all changes from develop are merged to the feature branch.
1 2
git checkout feature/PROJ-01_user_registration git pull origin develop
-
Resolve all conflicts (if any) and commit changes.
1
git commit -a -m "Conflicts resolved"
-
Finish the feature.
1
mvn jgitflow:feature-finish
-
Push changes from develop into remote repository
1
git push origin develop
-
Move JIRA task to “Done” category.
-
Verify that:
- Feature branch is merged into develop branch.
- Local feature branch is removed.
- Bamboo build plan for develop is green.
Start release branch
-
Create release branch.
1
mvn jgitflow:release-start
-
Verify that:
- New local release branch release/version is created.
- Work with release branch
Work with release branch
-
Clean the database (Database).
-
Run the application (Running Application) and perform exploratory tests.
-
Fix all issues (if any).
-
Commit changes to the release branch.
1
git commit -a -m "Fixes release candidate"
Finish release branch
-
Make sure your local master branch is up to date
1
git fetch origin master
-
Finish the release branch
1
mvn jgitflow:release-finish
- Verify that:
- Release branch is merged into local develop branch.
- Project version is updated in local develop branch.
-
Push changes from develop into remote repository
1
git push origin develop
-
Checkout master
1
git checkout master
- Verify that:
- Release branch is merged into local master branch.
- Project version is updated in local master branch.
-
Push changes from master into remote repository
1
git push --tags origin master
- Verify that:
- Release tag is pushed to the remote repository.
- Build plan on master is green and new version is deployed.
-
Delete released feature branches from remote repository.
1
git push origin :feature/PROJ-01_user_registration
Comments