Skip to content

Instantly share code, notes, and snippets.

@orclev
Last active October 12, 2023 16:57
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save orclev/db21dc1d848c231ea729 to your computer and use it in GitHub Desktop.
Save orclev/db21dc1d848c231ea729 to your computer and use it in GitHub Desktop.
Gitflow Examples

git flow usage

Start using git flow on a new repo or one you haven't used git flow on before

user@example ~/gitflow-example [master] $ git flow init
No branches exist yet. Base branches must be created now.
Branch name for production releases: [master] 
Branch name for "next release" development: [develop] 

How to name your supporting branch prefixes?
Feature branches? [feature/] 
Release branches? [release/] 
Hotfix branches? [hotfix/] 
Support branches? [support/] 
Version tag prefix? []
user@example ~/gitflow-example [develop] $

Start a new feature

user@example ~/gitflow-example [develop] $ git flow feature start new-feature
Switched to a new branch 'feature/new-feature'

Summary of actions:
- A new branch 'feature/new-feature' was created, based on 'develop'
- You are now on branch 'feature/new-feature'

Now, start committing on your feature. When done, use:

     git flow feature finish new-feature

user@example ~/gitflow-example [feature/new-feature] $

Push a feature branch to origin

user@example ~/gitflow-example [feature/new-feature] $ git flow publish new-feature
Counting objects: 5, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (5/5), 398 bytes | 0 bytes/s, done.
Total 5 (delta 0), reused 0 (delta 0)
To git@origin.com:user/gitflow-example.git
 * [new branch]      feature/new-feature -> feature/new-feature
Already on 'feature/new-feature'
Your branch is up-to-date with 'origin/feature/new-feature'.

Summary of actions:
- A new remote branch 'feature/new-feature' was created
- The local branch 'feature/new-feature' was configured to track the remote branch
- You are now on branch 'feature/new-feature'

user@example ~/gitflow-example [feature/new-feature] $

To complete a feature and merge it into develop

user@example ~/gitflow-example [feature/new-feature] $ git flow feature finish
Switched to branch 'develop'
Updating 075a61e..2e421c4
Fast-forward
 README.md | 1 +
 1 file changed, 1 insertion(+)
 create mode 100644 README.md
Deleted branch feature/new-feature (was 2e421c4).

Summary of actions:
- The feature branch 'feature/new-feature' was merged into 'develop'
- Feature branch 'feature/new-feature' has been removed
- You are now on branch 'develop'

user@example ~/gitflow-example [develop] $

To prepare a release

user@example ~/gitflow-example [develop] $ git flow release start v1.0.0
Switched to a new branch 'release/v1.0.0'

Summary of actions:
- A new branch 'release/v1.0.0' was created, based on 'develop'
- You are now on branch 'release/v1.0.0'

Follow-up actions:
- Bump the version number now!
- Start committing last-minute fixes in preparing your release
- When done, run:

     git flow release finish 'v1.0.0'

user@example ~/gitflow-example [release/v1.0.0] $

After cutting release to publish it back to master and begin next development cycle

user@example ~/gitflow-example [release/v1.0.0] $ git flow release finish 'v1.0.0'
Switched to branch 'master'
Merge made by the 'recursive' strategy.
 README.md         | 3 +++
 release_notes.txt | 1 +
 2 files changed, 4 insertions(+)
 create mode 100644 README.md
 create mode 100644 release_notes.txt
Switched to branch 'develop'
Merge made by the 'recursive' strategy.
 README.md         | 2 ++
 release_notes.txt | 1 +
 2 files changed, 3 insertions(+)
 create mode 100644 release_notes.txt
Deleted branch release/v1.0.0 (was 4731cf2).

Summary of actions:
- Latest objects have been fetched from 'origin'
- Release branch has been merged into 'master'
- The release was tagged 'v1.0.0'
- Release branch has been back-merged into 'develop'
- Release branch 'release/v1.0.0' has been deleted

user@example ~/gitflow-example [develop] $
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment