Git Workflow (GitHub Flow)
D5.0| Branch | Role |
Get This Skill on GitHubOverview
name: git-workflow description: "GitHub Flow guide. MUST invoke before starting any feature/fix implementation. Triggers: branch, commit, PR, implement, 구현, 새 기능"
Git Workflow (GitHub Flow)
Branch Strategy
| Branch | Role |
|---|---|
main | Always deployable, triggers auto-deploy |
| Work branches | feature/*, fix/*, refactor/*, docs/*, chore/* |
Branch Naming
| Prefix | Purpose | Example |
|---|---|---|
feature/ | New feature | feature/watchlist-export |
fix/ | Bug fix | fix/login-redirect |
refactor/ | Code refactoring | refactor/api-structure |
docs/ | Documentation | docs/api-guide |
chore/ | Config/maintenance | chore/update-deps |
Workflow
1. Create Branch
git checkout main
git pull origin main
git checkout -b feature/new-feature
2. Develop & Commit
git add .
git commit -m "feat: add feature description"
3. Push & Create PR
git push -u origin feature/new-feature
gh pr create --title "feat: description" --body "## Summary\n- Changes"
4. Merge & Cleanup
gh pr merge --merge
git checkout main
git pull
git branch -d feature/new-feature
Commit Message Format
<type>: <subject>
<body> (optional)
Types
| Type | Purpose |
|---|---|
feat | New feature |
fix | Bug fix |
refactor | Refactoring (no behavior change) |
docs | Documentation only |
chore | Config, deps, build |
test | Add/modify tests |
style | Formatting, semicolons |
perf | Performance improvement |
Examples
feat: add watchlist CSV export
fix: resolve login redirect issue
refactor: simplify API response handler
docs: add API documentation
chore: update dependencies
Branch Protection (main)
main 브랜치에 직접 push 금지, PR을 통해서만 머지.
GitHub 웹에서 설정
Settings > Branches > Add rule:
- Branch name pattern:
main - Require a pull request before merging
gh CLI로 설정
gh api repos/{owner}/{repo}/branches/main/protection -X PUT \
-H "Accept: application/vnd.github+json" \
--input - <<'EOF'
{
"required_status_checks": null,
"enforce_admins": true,
"required_pull_request_reviews": {
"dismiss_stale_reviews": false,
"require_code_owner_reviews": false,
"required_approving_review_count": 0
},
"restrictions": null
}
EOF
보호 규칙 확인
gh api repos/{owner}/{repo}/branches/main/protection
Exceptions
- Typos, single-line fixes:
direct commit toPR 필수mainallowed - No
devbranch needed (Preview deployment serves as staging)
Common Commands
# List branches
git branch -a
# Fetch remote
git fetch origin
# Update main
git checkout main && git pull
# Merge main into feature branch
git checkout feature/xxx
git merge origin/main
# Stash changes
git stash
git stash pop
# Undo commit (keep changes)
git reset --soft HEAD~1
# Discard file changes
git checkout -- filename
What This Skill Can Do
AI-generated examples showing real capabilities
Ready to use this skill?
Visit the original repository to get the full skill configuration and installation instructions.
View on GitHub