Master Git Branching and Commit Standards for Clean Code
This guide explains Git branch naming conventions, maps branches to development environments, outlines a standard merge workflow, details commit message standards—including Angular guidelines and a simplified format—and provides a sample .gitignore, offering practical tips for clean, maintainable code management.
Branch Naming
Defines purpose of master, develop, feature, test, release, and hotfix branches. Master is the stable production branch, develop holds the latest development code, feature branches are created from develop for new functionality, test is used for QA, release is for pre‑production, and hotfix addresses urgent issues based on master.
Branch‑Environment Mapping
Common environments include DEV for development, FAT for feature acceptance testing, UAT for user acceptance testing, and PRO for production. Each branch aligns with an environment, e.g., master → PRO, develop → DEV, test → FAT, release → UAT.
Branch Merge Process
A typical workflow: develop and hotfix branches are created from master; develop merges into test; after functional testing, test merges into release; after UAT, release merges into master. Small tasks (<1 day) may be done directly on develop; otherwise, use feature branches and merge back into develop.
Git Commit Message Guidelines
Well‑structured commit messages speed up code review, improve release notes, and help future maintainers. The Angular Git Commit Guidelines use the format
type(scope): subjectwith optional body and footer. Types include
feat(new feature),
fix(bug fix),
docs,
style,
refactor,
perf,
test,
chore, and others. A simplified version drops blank lines.
Single Commit Tips
Each commit should address a single category.
Limit a commit to no more than three issues.
If a commit does not follow the format, amend it with
git commit --amend -m "new message"or reset with
git reset --hard HEAD.
.gitignore Configuration
The
.gitignorefile lists files and directories that should not be committed. A generic example includes IDE configuration files, build output directories, log files, and common binary artifacts such as
*.jar,
*.war,
*.zip, etc.
Additional Recommendations
Tag each master update with a version number for easier management.
Delete feature and hotfix branches after they are merged to keep the repository tidy.
Commit local changes before pulling to avoid merge conflicts and potential code loss.
macrozheng
Dedicated to Java tech sharing and dissecting top open-source projects. Topics include Spring Boot, Spring Cloud, Docker, Kubernetes and more. Author’s GitHub project “mall” has 50K+ stars.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.