Fundamentals 8 min read

Mastering Git: Branch Naming, Workflow & Commit Message Standards

This guide explains how to structure Git branches—including master, develop, feature, release, and hotfix—provides command sequences for common tasks, and details a comprehensive commit‑message format based on the Angular convention to improve code review, release notes, and long‑term maintainability.

Code Ape Tech Column
Code Ape Tech Column
Code Ape Tech Column
Mastering Git: Branch Naming, Workflow & Commit Message Standards

Why Standardize Git Practices?

Git is the most widely used source‑code management tool. Consistent branch naming, clear workflow steps, and well‑structured commit messages help keep the repository organized, simplify maintenance, and make collaboration smoother.

Branch Naming Conventions

master : The main production branch. It should only receive merges from develop or hotfix and never be edited directly.

develop : The integration branch that always contains the latest completed features and bug fixes. New feature branches are created from develop.

feature branches: Created for each new feature, named with the prefix feature/ (e.g., feature/user_module, feature/cart_module).

release branches: Used for pre‑production testing. When a set of features is ready, they are merged into develop, then a release branch is created for testing. Bug fixes during testing are committed directly to the release branch, which is later merged back into both master and develop.

hotfix branches: Prefix hotfix/. Created from master to address urgent production issues, then merged back into both master and develop.

Common Git Tasks

Adding a New Feature

(dev)$: git checkout -b feature/xxx   # create feature branch from develop
(feature/xxx)$: ...                  # develop the feature
(feature/xxx)$: git add .
(feature/xxx)$: git commit -m 'commit comment'
(dev)$: git merge feature/xxx --no-ff   # merge back to develop

Fixing an Urgent Bug

(master)$: git checkout -b hotfix/xxx   # create hotfix branch from master
(hotfix/xxx)$: ...                     # fix the bug
(hotfix/xxx)$: git add .
(hotfix/xxx)$: git commit -m 'commit comment'
(master)$: git merge hotfix/xxx --no-ff   # merge to master (production)
(dev)$: git merge hotfix/xxx --no-ff      # sync hotfix to develop

Testing Environment Code

(release)$: git merge dev --no-ff   # merge develop into release for testing

Production Release

(master)$: git merge release --no-ff   # merge tested release into master
(master)$: git tag -a v0.1 -m 'deployment version'   # create a version tag

Commit Message Guidelines

Good commit messages speed up code review, generate useful release notes, and help future maintainers understand why changes were made.

The Angular Git Commit Guidelines are widely adopted. The basic structure is:

<type>(<scope>): <subject>

<body>

<footer>

Elements:

type : Category of the change (e.g., feat, fix, docs, style, refactor, perf, test, chore).

scope : Optional area affected by the change.

subject : Concise summary (imperative mood, no period, lower‑case first word).

body : Detailed description, wrapped at ~72 characters per line. Explain why the change is needed, how it solves the problem, and any side effects.

footer : References to related issues or breaking changes.

Example format (excerpt from the Angular guideline):

# Title line: ≤50 characters, describing the main change
#
# Body: detailed explanation, ≤72 characters per line
#   * Why is this change necessary?
#   * How does it solve the problem?
#   * Any side effects or risks?
#
# Footer: optional links to issues or documentation

Type Definitions

feat

: Add a new feature. fix: Fix a bug. docs: Documentation only changes. style: Formatting, whitespace, no code logic change. refactor: Code restructuring without adding features or fixing bugs. perf: Performance improvements. test: Add or modify tests. chore: Build process, dependencies, or other chores.

Visual Reference

Commit message format diagram
Commit message format diagram
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.

workflowGitbest practicesVersion Controlbranch namingcommit messages
Code Ape Tech Column
Written by

Code Ape Tech Column

Former Ant Group P8 engineer, pure technologist, sharing full‑stack Java, job interview and career advice through a column. Site: java-family.cn

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.