Skip to content

Instantly share code, notes, and snippets.

@devarda
Created January 6, 2020 15:31
Show Gist options
  • Select an option

  • Save devarda/54f65ef3add38d9abbbfe4478faff272 to your computer and use it in GitHub Desktop.

Select an option

Save devarda/54f65ef3add38d9abbbfe4478faff272 to your computer and use it in GitHub Desktop.

Git-flow

We use git-flow to have master and development branches, merging at ease when working on hotfixes, features or releases with auto-tagging. We set the tag prefix to v to be able to standardize release versions. In example v1.0.0.

  1. Installation https://github.com/nvie/gitflow/wiki/Installation
  2. Watch introduction if unfamiliar https://vimeo.com/16018419
  3. Setup on your local repo by going into this project's directory and typing git flow init. Press enter for every question except for tag-prefix: Type v and enter. This will automatically recognize master and develop branches and will set you on develop branch.

Git-flow tips

Git flow will automatically checkout develop branch. Here are some most commonly used scenarios:

  1. git flow release start 1.0.0 is only used when you are all committed in develop branch and need to tag. After you run the command, the only thing you need to do is update package.json version to 1.0.0 and commit. Then run git flow release finish 1.0.0 to automatically merge your release to develop and master branches and tag with v1.0.0
  2. git flow feature start my-great-feature is used when you want to branch out of develop into a new branch called feature/my-great-feature. When you are all committed in this branch and ready to bring master and develop up to the same level, simply run git flow feature finish my-great-feature and it will merge it for you, bringing you back to develop branch. We usually don't push feature branches up to remotes unless they need collaboration.
  3. When you forgot something while making a release, or want to add something to the master branch, use git flow hotfix start 1.0.1 to create a hotfix based on master. After you are all committed, run git flow hotfix finish 1.0.1 which will merge your changes to master and develop, also tagging the release as v1.0.1

Git-flow Reference

Here's a list of resources on GitHub.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment