Git
Git λ²μ κ΄λ¦¬ λͺ¨λ² κ΄λ‘ λ° μν¬νλ‘μ° κ°μ΄λ.
μ»€λ° λ©μμ§ μ»¨λ²€μ
Conventional Commits μ¬μ©
μ»€λ° λ©μμ§λ <type>: <description> νμμ λ°λ₯Έλ€:
feat: add form validation to login page
fix: prevent duplicate email check error on signup
docs: add installation guide to README
refactor: extract auth logic into separate module
test: add payment feature tests
chore: update dependencies
μ£Όμ νμ
| νμ
|
μ€λͺ
|
μμ |
feat |
μλ‘μ΄ κΈ°λ₯ μΆκ° |
feat: add dark mode support |
fix |
λ²κ·Έ μμ |
fix: prevent token deletion on logout |
docs |
λ¬Έμ λ³κ²½ (μ½λ λ³κ²½ μμ) |
docs: update API documentation |
style |
μ½λ ν¬λ§·ν
, μΈλ―Έμ½λ‘ λλ½ (λμ λ³κ²½ X) |
style: apply ESLint rules |
refactor |
리ν©ν λ§ (κΈ°λ₯ λ³κ²½ μμ) |
refactor: extract utility functions |
test |
ν
μ€νΈ μ½λ μΆκ°/μμ |
test: add login API tests |
chore |
λΉλ, μ€μ λ³κ²½ (src λ³κ²½ μμ) |
chore: update Webpack config |
perf |
μ±λ₯ κ°μ |
perf: implement lazy loading for images |
μμΈ νμ (μ νμ¬ν)
<type>(<scope>): <subject>
<body>
<footer>
μμ:
feat(auth): implement JWT-based authentication
- Issue access and refresh tokens
- Store refresh tokens in Redis
- Add token renewal API endpoint
Closes #123
μμ£Ό νλ μ€μ
git commit -m "bug fix"
git commit -m "fix: fix issue"
git commit -m "feat: implement login, signup, and password reset"
git commit -m "feat: add form validation to login page"
μ»€λ° λ©μμ§ μμ± κ°μ΄λλΌμΈ
- 첫 μ€μ 50μ μ΄λ΄ - κ°κ²°ν μμ½
- νμ¬ν μ¬μ© - "added" (X) β "add" (O)
- λͺ
λ Ήν μ΄μ‘° - "adds" (X) β "add" (O)
- 첫 κΈμ μλ¬Έμ -
Feat: (X) β feat: (O)
- λ§μΉ¨ν κΈμ§ -
feat: add feature. (X) β feat: add feature (O)
- λ³Έλ¬Έμ 72μλ§λ€ μ€λ°κΏ - κ°λ
μ± ν₯μ
- Why > What - λ³κ²½ν λ΄μ©λ³΄λ€ λ³κ²½ν μ΄μ λ₯Ό μ€λͺ
- μμ΄λ‘ μμ± - λ¦΄λ¦¬μ¦ λ
ΈνΈ μμ± λꡬμμ νΈνμ±μ μν΄
GitHub Flow μν¬νλ‘μ°
λΈλμΉ μ λ΅
main (νμ λ°°ν¬ κ°λ₯ν μν)
βββ feature/login-form
βββ fix/payment-error
βββ refactor/user-service
κΈ°λ³Έ λΈλμΉ
μ μ μ₯μ μμ± μ κΈ°λ³Έ λΈλμΉλ mainμ μ¬μ©νλ€ (κ³Όκ±°μ master λμ ):
git init -b main
git branch -m master main
git push -u origin main
git config --global init.defaultBranch main
μ°Έκ³ : GitHub, GitLab, Bitbucket λ± λλΆλΆμ Git νΈμ€ν
μλΉμ€λ 2020λ
λΆν° κΈ°λ³Έ λΈλμΉλ₯Ό mainμΌλ‘ μ¬μ©νλ€.
λΈλμΉ λ€μ΄λ°
feature/user-authentication
fix/header-layout-bug
refactor/payment-module
docs/api-documentation
test/user-service
chore/update-dependencies
μμ
νλ¦
git switch main
git pull origin main
git switch -c feature/dark-mode
git add .
git commit -m "feat: add dark mode toggle button"
git push origin feature/dark-mode
gh pr create --title "feat: add dark mode support" --body "..."
gh pr merge <PRλ²νΈ> --squash
git switch main
git pull origin main
git branch -d feature/dark-mode
PR λ³ν© μ λ΅
| μ λ΅ |
μ€λͺ
|
μΈμ μ¬μ© |
| Squash |
λͺ¨λ 컀λ°μ νλλ‘ ν©μΉ¨ |
κΈ°λ₯ λΈλμΉ (κΆμ₯) |
| Merge |
λ³ν© μ»€λ° μμ±, νμ€ν 리 보쑴 |
λ¦΄λ¦¬μ€ λΈλμΉ |
| Rebase |
μ ν νμ€ν 리 μ μ§, λ³ν© μ»€λ° X |
κ°λ¨ν λ³κ²½, κΉλν νμ€ν 리 |
gh pr merge 123 --squash
gh pr merge 123 --merge
gh pr merge 123 --rebase
Git νμ€ν 리 κ΄λ¦¬
Rebase
Interactive Rebase (μ»€λ° μ 리)
git rebase -i HEAD~3
μμ:
pick a1b2c3d feat: implement login feature
pick d4e5f6g fix: typo in variable name
pick g7h8i9j fix: rename variable for clarity
pick a1b2c3d feat: implement login feature
fixup d4e5f6g fix: typo in variable name
fixup g7h8i9j fix: rename variable for clarity
Rebase onto main (λΈλμΉ μ΅μ ν)
git switch main
git pull origin main
git switch feature/my-feature
git rebase main
git add .
git rebase --continue
git rebase --abort
Cherry-pick (νΉμ 컀λ°λ§ κ°μ Έμ€κΈ°)
git cherry-pick <commit-hash>
git cherry-pick <commit-hash1> <commit-hash2>
git add .
git cherry-pick --continue
Commit Amend (λ§μ§λ§ μ»€λ° μμ )
git commit --amend -m "fix: correct commit message"
git add forgotten-file.ts
git commit --amend --no-edit
Reset vs Revert
git reset --soft HEAD~1
git reset --mixed HEAD~1
git reset --hard HEAD~1
git revert <commit-hash>
git revert HEAD
Merge Conflict ν΄κ²°
Conflict λ°μ μλ리μ€
git merge main
git rebase main
Conflict ν΄κ²° κ³Όμ
git status
git add src/index.ts
git merge --continue
git rebase --continue
Conflict ν΄κ²° μ λ΅
git restore --ours <file>
git restore --theirs <file>
git merge --abort
git rebase --abort
μμ£Ό μ¬μ©νλ λͺ
λ Ήμ΄
λΈλμΉ μμ
(git switch)
git switch main
git switch feature/my-feature
git switch -c feature/new-feature
git switch -
git switch -c local-branch origin/remote-branch
μ°Έκ³ : Git 2.23+ (2019λ
8μ)λΆν° git switchλ₯Ό μ¬μ©νλ€. κΈ°μ‘΄ git checkoutμ λΈλμΉ μ ν, νμΌ λ³΅μ λ± μ¬λ¬ μν μ λ΄λΉν΄ νΌλμ μΌκΈ°νλ€. git switchλ λΈλμΉ μ νλ§ λ΄λΉνλ€.
νμΌ λ³΅μ (git restore)
git restore <file>
git restore --staged <file>
git restore --staged --worktree <file>
git restore --source=<commit-hash> <file>
μ°Έκ³ : git restoreλ νμΌ λ³΅μ μ μ© λͺ
λ Ήμ΄λ€. κΈ°μ‘΄ git checkout -- <file>μ λ체νλ€.
μν νμΈ
git stat