CrossComm git-flow cheatsheet

created by Daniel Kummer, this fork developed just for CrossComm

Efficient branching using git-flow by Vincent Driessen

Getting started

★ ★ ★

New Features

Start a feature

99% of work happens on feature branches.

Always start by switching to the develop branch, pulling down all updates and creating your branch:

$ git checkout develop
$ git pull
$ git checkout -b feature/my-feature-name

Feature commits

When working on your feature, make commits to this branch. Push them to GitHub.

$ git add -p
$ git commit
$ git push

Feature review

Have your team review your code by creating a Pull Request.

  • Merge target is 'develop'
  • Assign to everyone who can review.
  • Link the PR in your project's Slack channel.
$ gh pr create --base develop

Finish the feature

  • Use Github PR buttons.
  • Verify you're merging into 'develop'
  • Delete feature branches after merging.

When everything is merged, sync your local git repository:

$ git fetch -p
$ git checkout develop
$ git pull

New Releases

Start a release

Always branch from the desired commits on 'develop' (probably the most recent).

Use semver version naming convention for releases.

$ git checkout develop
$ git pull
$ git checkout -b release/v1.0.31

Release commits

Commits can be made on a release branch, but they must be limited to work specifically for preparing a release (bug fixes, documentation updates, version string updates)

$ git add -p
$ git commit
$ git push

Finish a release

Finishing a release is one of the bigger steps in git-flow. It is important to merge the release into 'main' and into 'develop'. This is also where we tag the release. Start by creating a pull request from the release to main.

Initiate a new pull request on Github. From release/v1.0.31 to 'main'.

$ gh pr create --head release/v1.0.31 --base main

Review the changes and merge using the github PR merge buttons.

Tag the release

$ git checkout main
$ git pull
$ git tag v1.0.31
$ git push origin --tags

Create a PR to merge release/v1.0.31 onto 'develop'.

$ gh pr create --head release/v1.0.31 --base develop

After merging into 'develop' AND 'main' the release branch can be deleted.

Hotfixes

Start a hotfix

A Hotfix works just like a release, except it's branched off main and merges back into main.

$ git checkout main
$ git pull
$ git checkout -b hotfix/my-emergency-fixes
$ git push
$ // commit and push...

Finish a hotfix

Merge into develop and main

$ gh pr create --head hotfix/my-emergency-fixes --base develop
$ gh pr create --head hotfix/my-emergency-fixes --base main

After merging into 'develop' AND 'main' the hotfix branch can be deleted.

More Resources

The Git flow helper can simplify some of the repetitive tasks and help ensure best practices (auto merging releases into main and develop + more).

★ ★ ★

Optional Helpers

The Git flow helper can simplify some of the repetitive tasks and help ensure best practices (auto merging releases into main and develop + more).

★ ★ ★

macOS

Git Flow Helper
brew install git-flow-avh
GitHub CLI
brew install gh

For detailed git flow installation instructions please visit the git flow wiki.

install git-flow