Brian Love
Angular + TypeScript Developer in Denver, CO

Git + git-flow

Reading time ~2 minutes

Using the Git-flow model with Git makes it easy to work on features, releases and hotfixes.

I have been using the GitHub app for Mac OS X for some side projects for awhile, and found it to be pretty useful. For some stuff, I ended up using terminal, but that was ok. For a new project, we recently migrated our SVN repository to a BitBucket Git repository, and have been learning a lot about SourceTree and git-flow.

This is the standard setup of your branches in git using the git-flow model:

  • master
  • develop
  • features/{JIRA Issue ID}
  • releases/{version number}
  • hotfixes/{JIRA Issue ID}

New Features

For a new features the work flow allows us to hum along on our work without interrupting others.

  • Create a new features/ branch based on the JIRA issue ID
  • Code, commit, repeat
  • Push any code that needs to be shared with another developer or for a code review
  • Finish the project, merging the branch back into develop and deleting the branch afterwards

You can use SourceTree to create the new feature, and to finish the feature. You can also use the terminal shell. The commands to start a new feature are:

$ git flow feature start {JIRA issue ID}

When you have completed the features, just execute:

$ git flow features finish {JIRA issue ID}

If you are ready to push your feature to the remote develop branch:

$ git flow feature publish {JIRA issue ID}

Hotfixes

For a critical/blocking issue that must be dealt with immediately, and pushed into our master (production) branch, the work flow is:

  • Create a new hotfixes/ branch based on the JIRA issue ID
  • Fix the bug and commit
  • Finish the hotfix

Bash command to start hotfix:

$ git flow hotfix start {JIRA issue ID}

Finish the hot fix:

$ git flow hotfix finish {JIRA issue ID}

Releases

When you have tested your code and are ready to create a new release, git flow makes it really easy to create a new release branch. In SourceTree, just create a new release and use the version string you want to identify this release with. If you are using the terminal enter the following bash command:

$ git flow release start {version id}

After you have created the new release branch, you can use this branch to make any final version number changes, or other necessary changes. Perform final QA testing using this release. Once QA tests are completed and pass successfully, you are ready to merge your release branch into the master branch. You can do this in SourceTree by going to Git Flow > Finish Release and select the release that you are merging into master, or enter:

$ git flow finish release {version id}

Conclusion

Git + git-flow = Happy Developers

Brian Love

Hi, I'm Brian. I am interested in TypeScript, Angular and Node.js. I'm married to my best friend Bonnie, I live in Denver and I ski (a lot).