Git Fundamentals and Workflow: A Complete Guide from Principles to Team Collaboration
- Published on
- ...
- Authors

- Name
- Huashan
- @herohuashan
In software development, a clear workflow is the cornerstone of efficient collaboration and stable releases. This article summarizes a Git workflow that has been validated in multiple projects. It is suitable for both rapid iteration by individual developers and scaled-up code collaboration by teams. The core design follows three principles: three-tier environment isolation, semantic versioning, and fast rollback capability.
Git Working Principles Basics
Before diving into workflows, understanding Git's basic working principles is crucial for understanding subsequent processes.

Git's Four Working Areas
Local Working Directory ──→ Staging Area ──→ Local Repository ──→ Remote Repository (GitHub)
📁 📦 🗄️ ☁️
- Working Directory: Where you actually edit files
- Staging Area: Temporarily stores changes about to be committed
- Local Repository: Database storing complete project history
- Remote Repository: Shared repository hosted on platforms like GitHub/GitLab
Core Command Quick Reference
| Command | Function | Data Flow |
|---|---|---|
git init | Initialize repository | Create local repository |
git clone | Clone repository | Remote → Local |
git add | Add to staging area | Working directory → Staging area |
git commit | Commit to local repository | Staging area → Local repository |
git push | Push to remote repository | Local repository → Remote repository |
git fetch | Get remote updates | Remote repository → Local repository (no merge) |
git pull | Pull and merge remote branch | Remote repository → Working directory (auto merge) |
git merge | Merge branches | Merge specified branch to current branch |
git status | View status | Display working directory and staging area status |
git log | View commit history | Display commit records |
git branch | Create/view branches | Branch management |
git checkout | Switch branches | Switch to specified branch |
git diff | View differences | Compare file differences |
Typical Work Cycle
vim main.py
git status
git add main.py
git commit -m "feat: add new feature"
# 5. Push to remote repository
git push origin main
# 6. Pull others' updates
git pull origin main
After understanding these basic concepts, we will introduce practical workflows suitable for different team sizes.
Overview
This guide contains two working modes:
- Single-person Mode (iterate directly on
development) — Fast, simple, suitable for project initial stage or personal projects - Multi-person Collaboration Mode (feature branches + Merge Request) — More standardized, reviewable, reduces interference, suitable for team collaboration
Can upgrade according to team size at any time; recommended to enable multi-person collaboration part when second developer joins or releases are frequent.
Common principle: Three-tier environment + Semantic versioning + Rollback capability.
Environment and branch correspondence:
- DEV:
development - QUAL:
master - PROD:
release-*(regex match)
Single-person shortest path: development → master → release-*. Multi-person collaboration path: feature-* → development → master → release-*.
Branch and Environment Mapping
| Branch | Purpose | Auto-deploy Environment | Domain Example |
|---|---|---|---|
development | Daily development & DEV smoke test | DEV | https://app-dev.example.com |
master | Release preparation validation (close to production) | QUAL | https://app-qual.example.com |
release-* | Production live version | PROD | https://app.example.com |
Note: The above domains are examples only, please replace with your actual development, test and production environment addresses.
Runtime variable: APPSTORE_ENV = dev / qual / prod.
Single-person Mode Workflow (For single developer stage)
1. Daily Development (development)
git checkout development
git pull
# Modify code
git add .
git commit -m "feat: describe this change"
git push # Trigger DEV deployment
Perform local/DEV smoke test: mainly focus on service startup, key pages or API returning normally.
2. Advance to QUAL (master)
First time without master:
git checkout development
git pull
git checkout -b master
git push -u origin master
Each subsequent release to QUAL:
git checkout development
git pull
git checkout master
git pull
git merge development # Single-person mode direct merge
# Resolve conflicts (if any) then:
git push # Deploy to QUAL
Do near-production validation in QUAL: network policy, permissions, performance, data correctness.
3. Release to PROD (release-*)
git checkout master
git pull
git checkout -b release-1.0.1
git push -u origin release-1.0.1 # Deploy to PROD
# Tag version (recommended)
git tag -a v1.0.1 -m "Release v1.0.1"
git push --tags
After completion, update RELEASE.md with new version notes.
4. Hotfix (Production issue found)
Fix directly on corresponding release-* branch:
git checkout release-1.0.1
git pull
# Make fix
git add .
git commit -m "fix: fix production xxx issue"
git push # Immediately update PROD
Then sync back to other branches to avoid code drift:
git checkout master
git pull
git merge release-1.0.1
git push
git checkout development
git pull
git merge release-1.0.1
git push
5. Rollback to Old Version
If new version is unstable:
git checkout release-1.0.0
# Confirm code is correct
git push # Re-trigger deployment (specific behavior depends on platform)
Extreme case to force current release back to old commit:
git checkout release-1.0.1
git reset --hard v1.0.0
git push -f
Single-person Mode Common Auxiliary Commands
# View commit brief history
git log --oneline --decorate --graph --all
# Branch differences
git diff master..development
# Current branch
git branch --show-current
Single-person Mode Minimal Checklist
- Develop and push verification on
development - After code is stable, merge to
masterdeploy QUAL - After QUAL validation passes, create
release-x.y.zdeploy PROD - Tag & update
RELEASE.md - Monitor production; hotfix or rollback if necessary
Version Naming and Tags
- Branch:
release-MAJOR.MINOR.PATCH - Tag:
vMAJOR.MINOR.PATCH - PATCH: Bug fixes or minor adjustments; MINOR: New compatible features; MAJOR: Breaking updates (requires migration scripts and rollback plan).
Resource Configuration Recommendations (K8S)
resources:
requests:
memory: 300Mi
limits:
memory: 750Mi
cpu: 750m
Don't set CPU requests; observe if memory peak approaches limit.
Environment Difference Example Code
import os
APP_ENV = os.getenv("APPSTORE_ENV", "dev")
if APP_ENV == "dev":
DEBUG = True
DB_FILE = "sqlite_dev.db"
elif APP_ENV == "qual":
DEBUG = False
DB_FILE = "sqlite_qual.db"
else: # prod
DEBUG = False
DB_FILE = "sqlite_prod.db"
When to Switch to Multi-person Workflow?
Should switch to feature branches when any of the following occurs:
- Second developer joins
- Release frequency increases causing DEV to be frequently overwritten
- Need systematic code review
- Need parallel development of multiple features without interference
Multi-person Workflow Core Differences (Summary)
| Single-person Mode | Multi-person Mode |
|---|---|
Commit directly on development | Each feature uses feature-* branch |
| merge development → master → release | MR review before merge |
| Fast iteration, simple structure | Better isolation and review, reduces mutual impact |
Can copy this file content when migrating to multi-person mode, remove single-person parts, and link in README.
High frequency, small steps, rollback capability; keep RELEASE.md synchronized with actual deployment.
Multi-person Collaboration Mode Workflow (feature branch workflow)
Objectives
In multi-person parallel development: isolate incomplete work, reduce risk of mutual deployment/test overwriting, introduce code review and quality gates, facilitate rollback and audit.
Branch Types and Human Semantics
| Branch | Description | Auto-deploy | Merge Target |
|---|---|---|---|
feature-<description> | Single feature/fix development | No | development |
development | Integrate recently completed features; DEV demo/smoke test | DEV | master |
master | Pre-release freeze validation (QUAL) | QUAL | release-* |
release-x.y.z | Production live code | PROD | (None, or subsequent hotfix) |
hotfix-<description> | Production emergency fix | Deployment depends on base release | Merge back to release/master/development |
Detailed Lifecycle Steps
- Planning: Use Issues or task board to break down requirements; establish naming conventions (e.g.
feature-import-parquet). - Create feature branch:
git checkout development
git pull
git checkout -b feature-import-parquet
git push -u origin feature-import-parquet
- Development and local validation: Run unit tests/manual acceptance; create draft MR if needed for early feedback from others.
- Code review (Merge Request):
feature-* -> development, must meet:
- Pass automated tests
- At least 1 Reviewer approval
- No blocking comments
- Auto-deploy DEV after merge: Perform centralized smoke test (UI, API, logs, resources).
- After multiple features aggregate and reach "release candidate" condition → Establish release freeze point: MR
development -> master; disable non-critical feature merges during freeze period. - QUAL validation: Security, permissions, performance, resources, compatibility; if fails: fix in new
feature-*then cycle again. - Create production branch:
git checkout master
git pull
git checkout -b release-1.2.0
git push -u origin release-1.2.0
git tag -a v1.2.0 -m "Release v1.2.0"
git push --tags
- Production monitoring: Logs, error rate, memory, restart count; hotfix if necessary. (
hotfix-*) - Hotfix process:
git checkout release-1.2.0
git pull
git checkout -b hotfix-export-null-bug
# After fix
git add .
git commit -m "fix: handle null value in export causing exception"
git push -u origin hotfix-export-null-bug
# MR hotfix-export-null-bug -> release-1.2.0 review
# After merge production updates, then sync:
git checkout master && git pull && git merge release-1.2.0 && git push
git checkout development && git pull && git merge release-1.2.0 && git push
- Rollback: If new release is unstable, switch back to old
release-*branch; or use Tag to force reset.
Review Guidelines (Checklist)
| Category | Key Points |
|---|---|
| Code Style | Pass formatting/static checks; no large sections of commented dead code |
| Security | No credential leaks; avoid hardcoded passwords; input validation |
| Performance | Avoid O(n^2) large loops; batch processing; lazy loading |
| Logging | No excessive debug logs left in production path; sensitive info desensitized |
| Testing | Unit/integration tests for new key logic; ensure CI green light |
| Documentation | Brief comments for complex algorithms or key processes; update README/RELEASE if necessary |
CI/CD Recommended Gates
- feature branch: Run fast unit tests + linter
- development merge: Run extended test matrix (examples/datasets)
- master merge: Security scan (dependencies / container images) + load/resource smoke test
- release branch: Final image signing + version locking + release announcement
Multi-person Mode Checklist (Team Version)
- Requirements breakdown and create Issue
- Create
feature-*branch and establish MR (draft/formal) - Code review passed + CI green light
- Merge to
developmenttrigger DEV deployment - Release candidate freeze and merge to
master(QUAL) - QUAL validation passed (automated + manual)
- Create
release-x.y.zbranch and tag deploy PROD - Monitor and record release (update
RELEASE.md) - Sync necessary hotfixes to all trunk branches
Branch Naming Convention Recommendations
| Type | Rule Example | Description |
|---|---|---|
| feature | feature-<module>-<action> e.g. feature-cleaning-refactor | Clear semantics, avoid too long |
| hotfix | hotfix-<issue> e.g. hotfix-null-snapshot | Point to production problem root cause |
| release | release-MAJOR.MINOR.PATCH | Corresponds to semantic versioning |
Typical Parallel Development Strategy
- Use short-lived feature branches (1–5 days).
- Avoid large comprehensive giant branches; break complex requirements into multiple feature branches serial or parallel.
- Regular (at least daily) sync
developmentto local to avoid large conflicts.
Common Pitfalls and Avoidance
| Pitfall | Consequence | Avoidance |
|---|---|---|
| Develop directly on master | QUAL/PROD quality unstable | Force work on feature branches; use protected branch strategy |
| Long unmerged large branches | Eventual merge conflicts huge, hard to test | Small commits, frequent rebase or merge development |
| Hotfix only changes release | Same issue recurs on other branches | Strictly execute "three-way" sync (release→master→development) |
| Direct merge without review | Defects/security vulnerabilities enter trunk | Define minimum Reviewer count + CI must pass |
| Tag and branch version inconsistent | Rollback difficult, lose version source | Release script auto-validate Tag matches release name |
Recommended Tools/Strategies
- Pre-commit hooks: Formatting, static scanning (flake8 / black / isort etc.).
- Auto-generate CHANGELOG: Parse Conventional Commits.
- Version auto-increment script (optional): Calculate next version based on commit types.
- Protected branches: Prohibit direct push to
master/release-*, must go through MR.
Multi-person mode emphasizes: Transparency (MR records) + Reviewable (Review) + Rollback capability (Tag + Release branch) + Stability (Multi-level Gates).
Related Posts
Enterprise Internal Development Flow vs GitHub Open Source Project Flow Comparison
Comparing enterprise three-environment release process (DEV QUAL PROD) with GitHub open source project CI/CD automation workflow, sharing pros and cons of two different development models and applicable scenarios.