git
27
总安装量
27
周安装量
#7426
全站排名
安装命令
npx skills add https://github.com/dalestudy/skills --skill git
Agent 安装分布
opencode
27
claude-code
27
cursor
27
mcpjam
26
zencoder
26
Skill 文档
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 ëì ):
# ì ì ì¥ì ì´ê¸°í ì main ë¸ëì¹ë¡ ìì
git init -b main
# ëë 기존 ì ì¥ììì 기본 ë¸ëì¹ ë³ê²½
git branch -m master main
git push -u origin main
# Git ì ì ì¤ì (모ë ì ì ì¥ìì ì ì©)
git config --global init.defaultBranch main
ì°¸ê³ : GitHub, GitLab, Bitbucket ë± ëë¶ë¶ì Git í¸ì¤í
ìë¹ì¤ë 2020ë
ë¶í° 기본 ë¸ëì¹ë¥¼ mainì¼ë¡ ì¬ì©íë¤.
ë¸ëì¹ ë¤ì´ë°
# íì: <type>/<description>
feature/user-authentication
fix/header-layout-bug
refactor/payment-module
docs/api-documentation
test/user-service
chore/update-dependencies
ìì íë¦
# 1. mainìì ìµì ìí ë°ê¸°
git switch main
git pull origin main
# 2. ì ë¸ëì¹ ìì±
git switch -c feature/dark-mode
# 3. ìì
í 커ë°
git add .
git commit -m "feat: add dark mode toggle button"
# 4. ì격 ë¸ëì¹ì í¸ì
git push origin feature/dark-mode
# 5. GitHubìì PR ìì±
gh pr create --title "feat: add dark mode support" --body "..."
# 6. ì½ë 리뷰 í mainì ë³í© (GitHub UI ëë CLI)
gh pr merge <PRë²í¸> --squash # ëë --merge, --rebase
# 7. ë¡ì»¬ main ì
ë°ì´í¸ ë° ë¸ëì¹ ìì
git switch main
git pull origin main
git branch -d feature/dark-mode
PR ë³í© ì ëµ
| ì ëµ | ì¤ëª | ì¸ì ì¬ì© |
|---|---|---|
| Squash | 모ë 커ë°ì íëë¡ í©ì¹¨ | ê¸°ë¥ ë¸ëì¹ (ê¶ì¥) |
| Merge | ë³í© ì»¤ë° ìì±, íì¤í 리 ë³´ì¡´ | ë¦´ë¦¬ì¤ ë¸ëì¹ |
| Rebase | ì í íì¤í 리 ì ì§, ë³í© ì»¤ë° X | ê°ë¨í ë³ê²½, ê¹ëí íì¤í 리 |
# Squash (ê¶ì¥ - ê¸°ë¥ ë¨ìë¡ ì»¤ë° ì 리)
gh pr merge 123 --squash
# Merge (íì¤í 리 ë³´ì¡´)
gh pr merge 123 --merge
# Rebase (ì í íì¤í 리)
gh pr merge 123 --rebase
Git íì¤í 리 ê´ë¦¬
Rebase
Interactive Rebase (ì»¤ë° ì 리)
# ìµê·¼ 3ê° ì»¤ë° ìì
git rebase -i HEAD~3
# ìëí°ìì ëª
ë ¹ì´ ì í
# pick â ì»¤ë° ì ì§
# reword â ì»¤ë° ë©ìì§ ìì
# edit â ì»¤ë° ìì
# squash â ì´ì 커ë°ì í©ì¹¨
# fixup â ì´ì 커ë°ì í©ì¹¨ (ë©ìì§ ì ê±°)
# drop â ì»¤ë° ìì
ìì:
# Before
pick a1b2c3d feat: implement login feature
pick d4e5f6g fix: typo in variable name
pick g7h8i9j fix: rename variable for clarity
# After (squash ì¬ì©)
pick a1b2c3d feat: implement login feature
fixup d4e5f6g fix: typo in variable name
fixup g7h8i9j fix: rename variable for clarity
Rebase onto main (ë¸ëì¹ ìµì í)
# 1. main ìµì í
git switch main
git pull origin main
# 2. feature ë¸ëì¹ë¥¼ main ìë¡ rebase
git switch feature/my-feature
git rebase main
# 3. ì¶©ë ë°ì ì
# - íì¼ ìì í
git add .
git rebase --continue
# - rebase ì·¨ìíê³ ì¶ë¤ë©´
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
# â ï¸ ì£¼ì: ì´ë¯¸ pushí 커ë°ì amend ê¸ì§ (íì¤í 리 ë³ê²½ë¨)
Reset vs Revert
# Reset - ì»¤ë° ì·¨ì (íì¤í 리 ìì )
git reset --soft HEAD~1 # 커ë°ë§ ì·¨ì, ë³ê²½ì¬í ì ì§
git reset --mixed HEAD~1 # ì»¤ë° + staging ì·¨ì, ë³ê²½ì¬í ì ì§ (기본ê°)
git reset --hard HEAD~1 # ì»¤ë° + ë³ê²½ì¬í 모ë ìì (ìí!)
# â ï¸ pushí 커ë°ì reset ê¸ì§ â revert ì¬ì©
# Revert - 커ë°ì ëë리ë ì ì»¤ë° ìì± (íì¤í 리 ë³´ì¡´)
git revert <commit-hash>
git revert HEAD # ë§ì§ë§ ì»¤ë° ëë리기
Merge Conflict í´ê²°
Conflict ë°ì ìë리ì¤
# mainì mergeíê±°ë rebaseí ë ì¶©ë ë°ì
git merge main
# ëë
git rebase main
# Auto-merging src/index.ts
# CONFLICT (content): Merge conflict in src/index.ts
Conflict í´ê²° ê³¼ì
# 1. ì¶©ë íì¼ íì¸
git status
# 2. íì¼ ì´ì´ì ìë ìì
# <<<<<<< HEAD (íì¬ ë¸ëì¹)
# ë´ ë³ê²½ì¬í
# =======
# ìë ë¸ëì¹ì ë³ê²½ì¬í
# >>>>>>> main
# 3. ë§ì»¤ ì ê±°íê³ ì½ë ìì
# 4. í´ê²°ë íì¼ staging
git add src/index.ts
# 5. Merge ìë£
git merge --continue
# ëë Rebase ê³ì
git rebase --continue
Conflict í´ê²° ì ëµ
# íì¬ ë¸ëì¹ ë³ê²½ì¬í ì°ì
git restore --ours <file>
# ìë ë¸ëì¹ ë³ê²½ì¬í ì°ì
git restore --theirs <file>
# merge ì·¨ì
git merge --abort
# rebase ì·¨ì
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)
# ìì
ëë í 리 íì¼ ë³µì (unstaged ë³ê²½ì¬í ì·¨ì)
git restore <file>
# Staging ì·¨ì (unstagedë¡ ëë림)
git restore --staged <file>
# ìì
ëë í 리 + Staging 모ë ë³µì
git restore --staged --worktree <file>
# í¹ì 커ë°ì íì¼ë¡ ë³µì
git restore --source=<commit-hash> <file>
ì°¸ê³ : git restoreë íì¼ ë³µì ì ì© ëª
ë ¹ì´ë¤. 기존 git checkout -- <file>ì ëì²´íë¤.
ìí íì¸
git status # ë³ê²½ì¬í íì¸
git log --oneline # ì»¤ë° íì¤í 리 (í ì¤)
git log --graph # ë¸ëì¹ ê·¸ëí
git diff # ë³ê²½ ë´ì© íì¸
git diff --staged # stagingë ë³ê²½ ë´ì©
git show <commit-hash> # í¹ì ì»¤ë° ìì¸ë³´ê¸°
Stash (ìì ì ì¥)
git stash # íì¬ ìì
ìì ì ì¥
git stash list # ì ì¥ë stash 목ë¡
git stash pop # ë§ì§ë§ stash ì ì© + ìì
git stash apply # ë§ì§ë§ stash ì ì© (ì ì§)
git stash drop # ë§ì§ë§ stash ìì
git stash clear # 모ë stash ìì
ì격 ì ì¥ì
git remote -v # ì격 ì ì¥ì íì¸
git fetch origin # ì격 ë³ê²½ì¬í ê°ì ¸ì¤ê¸° (ë³í© X)
git pull origin main # ì격 ë³ê²½ì¬í ê°ì ¸ì¤ê¸° + ë³í©
git push origin main # ë¡ì»¬ ë³ê²½ì¬í í¸ì
git push -f origin main # ê°ì í¸ì (â ï¸ ìí - í ìì
ì ê¸ì§)
ë³´ì ë° ì£¼ìì¬í
ì ë 커ë°íë©´ ì ëë íì¼
# .gitignoreì ì¶ê°
.env # íê²½ ë³ì (API í¤, ë¹ë°ë²í¸)
.env.local
*.key # ì¸ì¦ì í¤
*.pem
secrets/ # ìí¬ë¦¿ ëë í 리
node_modules/ # ìì¡´ì± (package.jsonì¼ë¡ ê´ë¦¬)
dist/ # ë¹ë 결과물
.DS_Store # macOS ìì¤í
íì¼
ì¤ìë¡ ì»¤ë°í ìí¬ë¦¿ ì ê±°
# â ï¸ íì¤í 리ìì ìì ìì (git filter-branch ëì BFG ì¬ì©)
brew install bfg
bfg --delete-files .env
git reflog expire --expire=now --all && git gc --prune=now --aggressive
# â ï¸ ì£¼ì: ì´ë¯¸ í¸ìíë¤ë©´ ìí¬ë¦¿ ì¦ì í기 í ì¬ë°ê¸ íì
Force Push ê¸ì§ (ê³µì ë¸ëì¹)
# â main/developì force push ì ë ê¸ì§
git push -f origin main
# â
ê°ì¸ feature ë¸ëì¹ììë§ íì©
git push -f origin feature/my-branch
GitHub CLI íì©
# PR ìì±
gh pr create --title "feat: add new feature" --body "Description..."
# PR ëª©ë¡ íì¸
gh pr list
# PR ìì¸ë³´ê¸°
gh pr view 123
# PR ì²´í¬ìì (ë¡ì»¬ìì í
ì¤í¸)
gh pr checkout 123
# PR ë³í©
gh pr merge 123 --squash
# Issue ìì±
gh issue create --title "Bug found" --body "Description..."