Skip to content

๐Ÿ‘ฅ Collaboration Workflows โ€‹

Gitflow Workflow โ€‹

Gitflow is a classic branch management strategy, suitable for projects with planned version releases.

text
Gitflow Branch Structure:

main โ”€โ”€โ”€โ”€โ”€โ—โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ—โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ—โ”€โ”€โ”€ (Production)
          โ”‚                โ†‘           โ†‘
          โ”‚                โ”‚           โ”‚
release โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ—โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜           โ”‚
          โ”‚      โ†‘                     โ”‚
          โ”‚      โ”‚                     โ”‚
develop โ”€โ”€โ—โ”€โ”€โ—โ”€โ”€โ”€โ—โ”€โ”€โ—โ”€โ”€โ—โ”€โ”€โ—โ”€โ”€โ—โ”€โ”€โ—โ”€โ”€โ”€โ”€โ”€โ”˜โ”€โ”€โ—โ”€โ”€ (Development mainline)
               โ†‘     โ†‘        โ†‘
               โ”‚     โ”‚        โ”‚
feature/xxx โ”€โ”€โ”€โ”˜     โ”‚        โ”‚
feature/yyy โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜        โ”‚
bugfix/zzz โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Branch descriptions:
โ€ข main: Production code, only accepts merges from release and hotfix
โ€ข develop: Development mainline, convergence point for all feature branches
โ€ข feature/*: Feature branches, created from develop, merged back to develop when complete
โ€ข release/*: Release branches, created from develop, merged to main and develop after testing
โ€ข hotfix/*: Hotfix branches, created from main, merged to main and develop after fix

GitHub Flow โ€” Simple is Beautiful โ€‹

GitHub Flow is much simpler than Gitflow, suitable for continuously deployed projects.

text
GitHub Flow Process:

1. The main branch is always deployable
2. Create a descriptive branch from main (e.g., add-login-page)
3. Develop and commit on the branch
4. Open a Pull Request
5. Merge to main after code review passes
6. Deploy immediately after merge

main โ”€โ”€โ—โ”€โ”€โ—โ”€โ”€โ—โ”€โ”€โ”€โ”€โ”€โ”€โ—โ”€โ”€โ”€โ”€โ”€โ”€โ—โ”€โ”€ (Always deployable)
        โ†‘     โ†‘      โ†‘
        โ”‚     โ”‚      โ”‚
   feat/a โ”€โ”€โ”˜     โ”‚
   PR + merge     โ”‚
                   โ”‚
         feat/b โ”€โ”€โ”€โ”˜
         PR + merge

Forking Workflow โ€” The Open Source Standard โ€‹

In open source projects, you typically don't have direct push access. The workflow is:

bash
# 1. Fork the repository on GitHub to your account

# 2. Clone your own fork
git clone git@github.com:yourname/open-source-project.git
cd open-source-project

# 3. Add the original repository as upstream
git remote add upstream git@github.com:original-author/open-source-project.git

# 4. Create a feature branch
git switch -c fix/fix-documentation-error

# 5. Develop, commit, push
git add .
git commit -m "docs: fix spelling errors in README"
git push origin fix/fix-documentation-error

# 6. Open a Pull Request on GitHub

# 7. Sync the latest code from upstream
git fetch upstream
git switch main
git merge upstream/main
git push origin main

Pull Request Best Practices โ€‹

  • One PR does one thing โ€” don't add features, fix bugs, and refactor code all in one PR
  • Write clear PR descriptions โ€” explain what changed, why, and how to test
  • Keep PRs small and focused โ€” nobody wants to review a 3000-line PR
  • Respond to review comments promptly โ€” don't keep reviewers waiting
  • Ensure CI passes before merging โ€” don't let failing test code into main