Skip to content

Instantly share code, notes, and snippets.

@bucker
Last active September 7, 2019 13:01
Show Gist options
  • Save bucker/17d811f898f61c11886c to your computer and use it in GitHub Desktop.
Save bucker/17d811f898f61c11886c to your computer and use it in GitHub Desktop.
Git Flow recipe

Git Flow Notes

Setup

$ brew install git-flow

Initialize git-flow inside an existing git repository

git flow init

Features

Typically exist in developers repos only

Start a New Feature

This creates a new branch based on develop and switches to it

git flow feature start MYFEATURE

Finish up a Feature

Merged MYFEATURE into develop, removes the feature branch, and switches back to develop:

git flow feature finish MYFEATURE

Publish a Feature

Push a feature branch to remote repository:

git flow feature publish MYFEATURE

Get a feature published by another user from remote repository:

git flow feature pull origin MYFEATURE
  • Delete a Git branch locally and remotely:

    • There are 3 different branches to delete:
      1. The local branch X
      2. The remote origin branch X
      3. The local remote-tracking branch origin/X that tracks the remote branch X
git branch -D bugfix // delete local branch
git push origin --delete BRANCH_NAME // delete the remote and local remote-tracking branch

Merge commit in develop branch to a feature branch

Use merge or rebase, generally it's better to use merge

git checkout feature
git merge develop

Release

Start a Release

Create release branch from develop:

git flow release start RELEASE

Publish release branch:

git flow release publish RELEASE

Create a local tracking branch for a remote release:

git flow release track RELEASE

Finish up a Release

Merge release branch into master, tags the release with its name, merge back into develop, and remove the release branch:

git flow release finish RELEASE
git push --tags

Hotfixes

Start a Hotfix

Create hotfix branch from master:

git flow hotfix start VERSION [BASENAME]

Finish a Hotfix

Merge hotfix back into develop and master, and tag:

git flow hotfix finish VERSION

Misc.

Push the develop branch to remote, use the regular git command

git push origin develop

References

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