← Back to Git Course | Chapter 6: Advanced Commands | Lesson 3 of 7

Git Workflows (GitFlow)

Initializing GitFlow

GitFlow is a branching model that assigns a specific role to each branch type — develop for ongoing integration, feature/* for new work, release/* for stabilization, hotfix/* for urgent production fixes — instead of everyone committing to one shared branch. It suits projects with scheduled releases where you need a clear separation between what's stable and what's in progress.

Example: Initializing GitFlow

bash
git checkout -b develop main
git checkout -b feature/login develop

Developing Features

A feature branch is cut from develop, built in isolation, and merged back into develop once finished — but that merge is a deliberate step you (or a pull request) trigger, not something GitFlow does automatically. Keeping features isolated this way means an unfinished feature never blocks or destabilizes what everyone else is integrating.

Example: Developing Features

bash
git checkout -b feature/cart develop
git checkout develop
git merge feature/cart

Preparing Releases

A release branch forks off develop once it has enough features for a release, and is used only for last-mile work — bug fixes, version bumps, documentation — never new features. When it's ready, it merges into both main (to ship it) and back into develop (so those same fixes aren't lost from ongoing work).

Example: Preparing Releases

bash
git checkout -b release/1.0 develop
git checkout main
git merge release/1.0
git checkout develop
git merge release/1.0

Executing Hotfixes

A hotfix branch forks directly from main so it can patch a live production bug without waiting for whatever's currently in progress on develop. Like a release branch, it merges into both main and develop when done, ensuring the fix ships immediately and isn't accidentally reverted by the next regular release.

Example: Executing Hotfixes

bash
git checkout -b hotfix/critical-bug main
git checkout main
git merge hotfix/critical-bug
git checkout develop
git merge hotfix/critical-bug

Publishing Features

Pushing a local feature branch to the remote (git push -u origin feature/x) is what turns a private, local branch into something teammates can see, check out, and collaborate on — usually the point at which you'd also open a pull request for early feedback.

Example: Publishing Features

bash
git push -u origin feature/x
🔒

Chapter Quiz — Complete all 7 topics to unlock

0/7 topics done

Complete these topics first:

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.