Git Branching Workflow
Dev Guides / git-branching.html
A step-by-step basic workflow: work on a feature branch, review, then merge.
๐ฌ Keep main always working; do work on a branch.
- Branch: an isolated line of work.
- Commit: a recorded change unit.
- Merge: combine one branch's changes into another.
Step by step
# 1) move to up-to-date main
git switch main
git pull
# 2) create a feature branch
git switch -c feature/login
# 3) work, then record
git add -A
git commit -m "feat: add login form"
# 4) push and open a PR
git push -u origin feature/login
Clean up after merge
git switch main
git pull
git branch -d feature/login
Common problems
- Conflict: both sides changed the same lines. Resolve the
<<<<<<<markers and commit again. - main moved ahead:
git rebase mainreplays your branch on top.
Sources
- Official docs git-scm.com/doc โ Official docs
- Official docs Pro Git (Korean) โ Free book
Verified date indicates freshness. Check applicability conditions for older material.