Fundamentals 8 min read

Why Use Git Workflows? Master Trunk-Based, GitFlow, Feature & Forking Strategies

Discover the purpose of Git workflows, compare trunk‑based development, GitFlow, feature‑branch, and forking strategies, and learn step‑by‑step commands for initializing, creating, merging, and releasing branches to improve collaboration, reduce conflicts, and enable continuous integration and delivery.

Code Mala Tang
Code Mala Tang
Code Mala Tang
Why Use Git Workflows? Master Trunk-Based, GitFlow, Feature & Forking Strategies

What is a Workflow? Why Use It?

Today we explain what a workflow is and why you should adopt one. A workflow defines how you and your team collaborate with Git and GitHub. Choosing the right workflow depends on team structure, project complexity, and your release strategy. Below are the most common workflows and their use cases.

Trunk‑Based Development

This is the most widely used workflow; you may already be using it without knowing its name. Developers work directly on the main branch or create short‑lived feature branches, merging changes to main multiple times a day. Frequent integration minimizes merge conflicts and enables fast delivery, real‑time collaboration, and fewer conflicts.

Workflow Steps

Start work: git checkout -b feature-article Make changes and push frequently: git commit -m "Finish Article" Merge branch:

git checkout main
git merge feature-article
git push origin main

GitFlow

Unlike a single main branch, GitFlow maintains two primary branches: main (production) and dev (integration). From dev you create other branches:

Feature branches : created from dev and merged back after completion.

Release branches : created from dev when preparing a release.

Hotfix branches : created from main to fix urgent issues, then merged into both main and dev .

main always stores production code, while dev integrates all feature branches. Development occurs on dev to avoid working directly on production code. GitFlow is ideal for CI/CD.

Workflow Steps

Initialize GitFlow: git flow init During initialization you answer prompts such as which branches to use for production ( main ) and next‑release integration ( dev ), and the prefixes for feature, bugfix, release, hotfix, etc.

Start a new feature: git flow feature start feature-article Finish the feature: git flow feature finish feature-article This merges the feature into dev , deletes the feature branch, and switches back to dev .

Publish the feature (optional): git flow feature publish feature-article Create a release branch: git flow release start v1.0 Finish and deploy the release: git flow release finish 'v1.0' The command merges the release into main , tags the release, back‑merges the tag into dev , deletes the release branch, and leaves you on dev . Sample output includes branch switches, merge summaries, and tag creation.

Feature Branch Workflow

This workflow suits teams developing multiple features simultaneously. Each feature lives in its own branch and is merged into main after review.

Workflow Steps

Create a feature branch: git checkout -b feature-article Work and commit changes:

git add .
git commit -m "Added Feature Branch Topic"

Push the branch and open a Pull Request: git push origin feature-article After review, merge the changes into the remote and local main branch.

Forking Workflow

Developers fork a repository (instead of working directly on the original), clone their fork, create branches, push changes to their fork, and submit a Pull Request to the original repository. This is common in open‑source projects.

Workflow Steps

Fork the repository on GitHub.

Clone the forked repository:

git clone https://github.com/lorenzouriel/ebook-git-github.git

Create a branch and make changes:

git checkout -b feature-article
git add .
git commit -m "Added feature article"
git push origin feature-article

Submit a Pull Request to the original repository.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

branching
Code Mala Tang
Written by

Code Mala Tang

Read source code together, write articles together, and enjoy spicy hot pot together.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.