Bird
Raised Fist0
Gitdevops~10 mins

Gitflow workflow - Step-by-Step Execution

Choose your learning style10 modes available

Start learning this pattern below

Jump into concepts and practice - no test required

or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Process Flow - Gitflow workflow
Start: master branch
Create develop branch
Feature branch created from develop
Feature development
Merge feature into develop
Create release branch from develop
Test and fix release
Merge release into master and develop
Tag release on master
Create hotfix branch from master if needed
Fix hotfix
Merge hotfix into master and develop
Tag hotfix on master
End
This flow shows how Gitflow organizes work by branching from master to develop, then feature branches, release branches, and hotfixes, merging back in a controlled way.
Execution Sample
Git
git checkout -b develop master
# Create develop branch from master

git checkout -b feature/login develop
# Start feature branch

git commit -m "Add login feature"
# Work on feature

git checkout develop

git merge feature/login
# Merge feature back to develop
This code shows creating develop from master, making a feature branch, committing work, and merging the feature back to develop.
Process Table
StepCommandBranch Created/Checked OutActionResulting Branch State
1git checkout -b develop masterdevelopCreate develop branch from masterdevelop branch created, points to master commit
2git checkout -b feature/login developfeature/loginCreate feature branch from developfeature/login branch created, points to develop commit
3git commit -m "Add login feature"feature/loginAdd commit to feature branchfeature/login advanced by one commit
4git checkout developdevelopSwitch back to develop branchHEAD on develop branch
5git merge feature/logindevelopMerge feature branch into developdevelop branch updated with feature commits
6git checkout -b release/1.0 developrelease/1.0Create release branch from developrelease/1.0 branch created for final testing
7git commit -m "Fix bugs"release/1.0Fix bugs on release branchrelease/1.0 advanced by bug fix commits
8git checkout mastermasterSwitch to master branchHEAD on master branch
9git merge release/1.0masterMerge release into mastermaster updated with release changes
10git tag -a v1.0 -m "Release 1.0"masterTag release on masterTag v1.0 created on master
11git checkout developdevelopSwitch to develop branchHEAD on develop branch
12git merge release/1.0developMerge release back into developdevelop updated with release fixes
13git checkout -b hotfix/1.0.1 masterhotfix/1.0.1Create hotfix branch from masterhotfix branch created for urgent fix
14git commit -m "Fix critical bug"hotfix/1.0.1Fix bug on hotfix branchhotfix branch advanced by fix commit
15git checkout mastermasterSwitch to master branchHEAD on master branch
16git merge hotfix/1.0.1masterMerge hotfix into mastermaster updated with hotfix
17git tag -a v1.0.1 -m "Hotfix 1.0.1"masterTag hotfix on masterTag v1.0.1 created on master
18git checkout developdevelopSwitch to develop branchHEAD on develop branch
19git merge hotfix/1.0.1developMerge hotfix into developdevelop updated with hotfix
20---Workflow cycle complete, ready for next feature
💡 Workflow cycle complete after merging hotfix back to develop and tagging master
Status Tracker
BranchStartAfter Step 1After Step 2After Step 3After Step 5After Step 6After Step 7After Step 9After Step 12After Step 16After Step 19Final
masterinitial commitinitial commitinitial commitinitial commitinitial commitinitial commitinitial commitrelease mergedrelease mergedhotfix mergedhotfix mergedhotfix merged
develop-created from mastersame as mastersame as mastermerged feature/loginsame as step 5same as step 5same as step 5merged releasesame as step 9merged hotfixmerged hotfix
feature/login--created from developcommit addedmerged into develop-------
release/1.0----created from developbug fix commit------
hotfix/1.0.1---------created from masterfix commitmerged into master and develop
Key Moments - 3 Insights
Why do we create a develop branch instead of working directly on master?
Develop branch acts as a preparation area for new features before they are stable enough for master. See execution_table steps 1 and 2 where develop is created from master and features branch from develop.
Why merge release branch back into both master and develop?
Release branch fixes and final changes must be in master for production and also in develop to keep future work up to date. See execution_table steps 9 and 12.
What is the purpose of hotfix branches?
Hotfix branches fix urgent bugs on production (master) and then merge fixes back to develop to keep all branches consistent. See execution_table steps 13-19.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table at step 3, what happens on the feature/login branch?
AThe develop branch is merged into feature/login
BThe feature/login branch is deleted
CA commit is added to the feature/login branch
DThe master branch is updated
💡 Hint
Check the 'Action' and 'Resulting Branch State' columns at step 3 in the execution_table
At which step is the release branch merged into master?
AStep 7
BStep 9
CStep 12
DStep 16
💡 Hint
Look for the command 'git merge release/1.0' and the branch 'master' in the execution_table
If a hotfix is needed, which branch is it created from according to the variable_tracker?
Amaster
Bdevelop
Cfeature/login
Drelease/1.0
💡 Hint
Check the 'hotfix/1.0.1' row in variable_tracker and see its origin branch
Concept Snapshot
Gitflow workflow uses multiple branches:
- master: production-ready code
- develop: integration branch for features
- feature branches: for new features from develop
- release branches: prepare new production release
- hotfix branches: urgent fixes from master
Merge back in order: feature->develop, release->master+develop, hotfix->master+develop
Tag releases on master for versioning.
Full Transcript
Gitflow workflow organizes code changes using branches. It starts with a master branch for production. A develop branch is created from master to integrate new features. Feature branches are created from develop to work on individual features. After features are done, they merge back into develop. When ready for release, a release branch is created from develop for final testing and fixes. The release branch is merged into master and develop, and tagged on master. If urgent fixes are needed, hotfix branches are created from master, fixed, then merged back into master and develop, and tagged on master. This keeps production stable and development organized.

Practice

(1/5)
1. What is the main purpose of the develop branch in the Gitflow workflow?
easy
A. It serves as the integration branch for features before release.
B. It contains the production-ready code only.
C. It is used to fix urgent bugs directly in production.
D. It stores experimental code that is not stable.

Solution

  1. Step 1: Understand the role of the develop branch

    The develop branch is where all completed features are merged and tested together before release.
  2. Step 2: Compare with other branches

    The master branch holds production-ready code, hotfix branches fix urgent bugs, and experimental code is not part of Gitflow standard branches.
  3. Final Answer:

    It serves as the integration branch for features before release. -> Option A
  4. Quick Check:

    Develop = integration branch [OK]
Hint: Develop branch integrates features before release [OK]
Common Mistakes:
  • Confusing develop with master branch
  • Thinking develop is for hotfixes
  • Assuming develop holds only stable code
2. Which command correctly starts a new feature branch named login using Gitflow?
easy
A. git flow start feature login
B. git flow feature start login
C. git start feature login
D. git feature start login

Solution

  1. Step 1: Recall Gitflow feature start syntax

    The correct syntax to start a feature branch is git flow feature start <name>.
  2. Step 2: Check each option

    Only git flow feature start login matches the correct syntax exactly. Others have incorrect order or missing 'flow'.
  3. Final Answer:

    git flow feature start login -> Option B
  4. Quick Check:

    Feature start = git flow feature start [OK]
Hint: Use 'git flow feature start <name>' to start features [OK]
Common Mistakes:
  • Omitting 'flow' in the command
  • Swapping command word order
  • Using 'git start' instead of 'git flow feature start'
3. Given the commands below, what is the final branch after finishing a release?
git flow release start 1.0.0
git flow release finish 1.0.0
medium
A. The branch is switched to master.
B. The branch is switched to develop.
C. The branch remains on release/1.0.0.
D. The branch is switched to feature/1.0.0.

Solution

  1. Step 1: Understand what 'git flow release finish' does

    This command merges the release branch into both master and develop, tags the release, and deletes the release branch.
  2. Step 2: Identify the branch after finishing release

    After finishing, Gitflow switches to master branch by default.
  3. Final Answer:

    The branch is switched to master. -> Option A
  4. Quick Check:

    Release finish switches to master [OK]
Hint: Release finish merges and switches to master [OK]
Common Mistakes:
  • Assuming branch stays on release
  • Thinking it switches to develop
  • Confusing feature branches with release
4. You ran git flow feature finish login but your changes are not in develop. What is the likely problem?
medium
A. You forgot to push the develop branch after finishing the feature.
B. You did not commit changes before finishing the feature.
C. You started the feature branch from master instead of develop.
D. You finished the feature on the master branch.

Solution

  1. Step 1: Recall feature branch base in Gitflow

    Feature branches should start from develop to ensure changes merge back there.
  2. Step 2: Analyze why changes are missing in develop

    If the feature branch was started from master, finishing it merges changes into master, not develop, causing missing updates in develop.
  3. Final Answer:

    You started the feature branch from master instead of develop. -> Option C
  4. Quick Check:

    Feature base must be develop [OK]
Hint: Feature branches must start from develop [OK]
Common Mistakes:
  • Assuming finishing auto-pushes changes
  • Not committing before finishing
  • Confusing master and develop as base
5. Your team wants to prepare a hotfix for a critical bug in production while a release is in progress. According to Gitflow, which sequence of commands correctly handles this situation?
hard
A. git flow hotfix start fix-bug; git flow release finish; git flow hotfix finish fix-bug
B. git flow release finish; git flow hotfix start fix-bug; git flow hotfix finish fix-bug
C. git flow feature start fix-bug; git flow feature finish fix-bug
D. git flow hotfix start fix-bug; git flow hotfix finish fix-bug

Solution

  1. Step 1: Understand hotfix purpose in Gitflow

    Hotfix branches are created from master to quickly fix production bugs, independent of ongoing releases.
  2. Step 2: Check command sequence for hotfix

    Starting and finishing a hotfix with git flow hotfix start and git flow hotfix finish is the correct way, regardless of release status.
  3. Step 3: Evaluate options

    git flow hotfix start fix-bug; git flow hotfix finish fix-bug correctly starts and finishes the hotfix. git flow release finish; git flow hotfix start fix-bug; git flow hotfix finish fix-bug delays hotfix until release finishes, which is not required. git flow feature start fix-bug; git flow feature finish fix-bug uses feature instead of hotfix. git flow hotfix start fix-bug; git flow release finish; git flow hotfix finish fix-bug incorrectly mixes release finish before hotfix finish.
  4. Final Answer:

    git flow hotfix start fix-bug; git flow hotfix finish fix-bug -> Option D
  5. Quick Check:

    Hotfix runs independently during release [OK]
Hint: Hotfix branches start and finish independently from release [OK]
Common Mistakes:
  • Waiting for release to finish before hotfix
  • Using feature branch for hotfix
  • Finishing release before hotfix finish