# 8. GitFlow: Key Branches

#### **Master Branch**

The **`master`** branch in GitFlow is reserved for production-ready code. It reflects the codebase's current state in production. Every time a release branch is finished, it gets merged into **`master`** and tagged with a version number, ensuring that every commit in the master branch is a new release.

**Key Points:**

* Represents the production-ready state.
* Only updated by merging release or hotfix branches.
* Every commit should be tagged with a version number.

#### **Develop Branch**

The **`develop`** branch is the branch where all the development happens and where the latest changes reside. It's the branch from which feature branches are created and into which they are merged. When the code in the **`develop`** branch reaches a stable point and is ready for release, a release branch is created.

**Key Points:**

* Contains the latest delivered and approved features.
* All feature branches branch off from and merge back into **`develop`**.
* Acts as an integration branch for features.

#### **Feature Branches**

Feature branches are used to develop new features or enhancements. They branch off from the **`develop`** branch and must merge back into **`develop`** once the feature is complete and tested.

**Key Points:**

* Branch off from **`develop`**.
* Must merge back into **`develop`**.
* Naming convention often like: **`feature/feature-name`** or **`feature/feature-description`**.
* Allows parallel development of features without affecting the main codebase.

#### **Release Branches**

Release branches support the preparation for a new production release. They allow for last-minute dotting of i's and crossing t's: minor bug fixes, documentation updates, etc. Once the release is ready to ship, it gets merged into **`master`** and tagged with a version number. It also needs to be merged back into **`develop`**, which may have progressed since the release was initiated.

**Key Points:**

* Branch off from **`develop`**.
* Must merge back into **`master`** and **`develop`**.
* Naming convention often like: **`release/version-number`** or **`release/release-name`**.
* Only bug fixes, documentation generation, and other release-oriented tasks should go in here.

#### **Hotfix Branches**

Hotfix branches are a quick way to fix critical production issues. They branch off from the **`master`** branch and represent the quickest path to patching the production version. Once the fix is complete, the hotfix branch is merged into both **`master`** (and tagged) and **`develop`** to ensure the fix is applied to the current development state as well.

**Key Points:**

* Branch off from **`master`**.
* Must merge back into both **`master`** and **`develop`**.
* Naming convention often like: **`hotfix/fix-description`** or **`hotfix/version-number`**.
* Used to quickly patch production releases.

In summary, GitFlow's branching model provides a structured way to manage different aspects of development, ensuring that the codebase remains organized, and releases are systematic and predictable.
