| Strategy | Best for | Key structures |
|---|---|---|
| ---------- | ---------- | ---------------- |
| GitHub Flow | Continuous deployment, small teams | main + feature branches → PR → deploy |
| GitFlow | Release cycles, multiple versions | main → develop → feature/ → release/ → hotfix/* |
| Trunk-based | CI/CD, large teams | Short-lived feature branches → merge to main daily |
| GitLab Flow | Environments per branch | main → pre-production → production |
Follow Conventional Commits:
feat: add user authentication
fix(api): handle null response from payment gateway
chore(deps): upgrade express to 4.18
docs(readme): update installation guide
refactor(db): extract query builder
test(auth): add login flow tests
git checkout -b feat/my-feature main
# ... code, commits ...
git push -u origin feat/my-feature
# → Open PR on GitHub/GitLab/Azure DevOps
git fetch origin
git rebase origin/main
# fix conflicts if any
git push --force-with-lease
git rebase -i HEAD~3
# pick, squash, reword, edit as needed
git push --force-with-lease
Strategy:
git merge → resolve conflicts in filesgit add git merge --continueFor rebase conflicts:
git rebase --continue # after resolving each step
git rebase --abort # to cancel
git rebase --skip # to skip a commit
git reset --soft HEAD~1git reset --hard HEAD~1git reflog → find SHA → git checkout -b git revert (safe for shared branches)git config --global alias.lg "log --oneline --graph --decorate --all"
git config --global alias.undo "reset --soft HEAD~1"
git config --global alias.amend "commit --amend --no-edit"
See references/workflows.md for detailed workflow patterns.
共 1 个版本