Git & GitHub Course
Git & GitHub
/
Intermediate

Hotfix Branches

Definition

Branches created to quickly patch production releases without interrupting pending changes on the development branch.

Explain Like I'm New

A fire alarm. Production is completely broken, users can't buy products, and the company is losing $10,000 an hour. You cannot wait for the standard 2-week Sprint. You branch DIRECTLY off `main`, fix the bug in 5 minutes, and merge it immediately back to `main`.

Real World Example

Fixing a typo on the homepage pricing table that accidentally says '$1' instead of '$100'.

Common Use Cases

  • •Emergency production patches

Terminal Output

bash / terminal
# FIRE ALARM! Production is broken! # 1. Branch straight off the live code (main) $ git checkout main $ git checkout -b hotfix-pricing-typo # 2. Fix the typo, test it, commit it $ git commit -am "Fix critical pricing typo" # 3. Merge immediately to main and deploy $ git checkout main $ git merge hotfix-pricing-typo # 4. Crucial: Merge back to the development branch so it isn't lost! $ git checkout develop $ git merge hotfix-pricing-typo

Interview Questions

basic

  • Which branch do you typically branch off of to create a hotfix?

intermediate

  • After merging a hotfix into `main`, where else must you merge it?

Flash Cards

Question

Which branch?

Click to reveal answer
Answer

You branch directly off `main` (or the specific release branch currently in production), because `main` represents the live state of the website.

Question

Where else?

Click to reveal answer
Answer

You MUST merge it back into `develop` (or your active feature branches). If you don't, the next time `develop` merges into `main`, the bug will be reintroduced!