Master Git‑Flow: A Step‑by‑Step Guide to Efficient Branch Management
Learn how to set up and use Git‑Flow for efficient project development, covering installation, branch strategies, feature, release, and hotfix workflows with practical command examples and visual diagrams to help teams maintain clean, organized repositories.
Recently I started defining development standards and decided to adopt Git version control, with Git‑Flow as the preferred workflow.
Why Use Git‑Flow
When using a version control system in a team, agreeing on a unified workflow is crucial. Git can do many things, but without an effective workflow, chaos is inevitable.
Installing Git‑Flow
We use Homebrew to install git‑flow: brew install git-flow Then initialize the project: git flow init Accept the default configuration prompts.
Branch Model
Git‑Flow defines two long‑living branches:
master – contains production‑ready code and should never be worked on directly.
develop – the integration branch for features and the base for release branches.
Supporting branches are created as needed and deleted after merging:
Feature branches: feature/ Release branches: release/ Hotfix branches: hotfix/ Support branches: support/ Long‑living branches persist throughout the project lifecycle.
Feature Branch Workflow
Start a feature: git flow feature start test1 Develop, commit changes:
git add .
git commit -m 'feat: add console.log'Finish the feature and merge back to develop: git flow feature finish test1 The command creates the feature branch, switches to it, and after finishing, merges it into develop and deletes the feature branch.
Release Branch Workflow
When ready to release a new version: git flow release start 0.1.0 Perform any last‑minute fixes, then finish the release: git flow release finish '0.1.0' This merges the release branch into both master and develop, tags the release, and deletes the release branch.
Hotfix Workflow
For urgent production fixes: git flow hotfix start jartto Apply fixes, commit, then finish: git flow hotfix finish 'jartto' The hotfix branch is created from master, merged back into master and develop, tagged, and then deleted.
Git‑Flow Diagram
References
https://www.git-tower.com/learn/git/ebook/cn/command-line/advanced-topics/git-flow
https://jeffkreeftmeijer.com/git-flow/
https://blog.csdn.net/aaaaaaliang/article/details/79451598
https://www.oschina.net/translate/a-successful-git-branching-model?print
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Programmer DD
A tinkering programmer and author of "Spring Cloud Microservices in Action"
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
