# Git Workflow

> Git workflow guide for feature branches, PRs, and releases. Trigger: branching, commits, PRs, git workflow, merge, release, conventional commits

- Skill: `jnzader-vault/git-workflow` (Agent Skill)
- Install (CLI): `npx skillmds@latest add jnzader-vault/git-workflow`
- Raw SKILL.md: https://api.skillmd.com/api/skills/jnzader-vault/git-workflow/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Productivity
- Author: jnzader-vault (https://skillmd.com/u/jnzader-vault)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/jnzader-vault/git-workflow

---


# Git Workflow

GitHub Flow with develop branch for integration.

## Branch Strategy

```
main (production)
  ↑ PR (release)
develop (integration)
  ↑ PR (feature complete)
feature/xxx (work)
```

## Branch Naming

| Type | Pattern | Example |
|------|---------|---------|
| Feature | `feature/t-xxx-description` | `feature/t-001-add-auth` |
| Fix | `fix/t-xxx-description` | `fix/t-015-login-bug` |
| Hotfix | `hotfix/xxx` | `hotfix/critical-security` |
| Release | `release/vX.Y.Z` | `release/v2.1.0` |

## Daily Workflow

### Start Work
```bash
# Update develop
git checkout develop
git pull origin develop

# Create feature branch
git checkout -b feature/t-001-description
```

### During Work
```bash
# Stage changes
git add <specific-files>

# Commit (conventional format)
git commit -m "feat(scope): description"

# Push (CI-Local validates first)
git push -u origin feature/t-001-description
```

### Create PR
```bash
gh pr create --base develop --title "feat: T-001 description" --body "
## Summary
- What this PR does

## Test Plan
- How to test

## Related
- Closes #123
"
```

### After Review
```bash
# Merge PR (squash recommended)
gh pr merge <number> --squash

# Delete local branch
git checkout develop
git branch -d feature/t-001-description
```

## Commit Convention

Format: `type(scope): description`

### Types
| Type | Use |
|------|-----|
| `feat` | New feature |
| `fix` | Bug fix |
| `refactor` | Code change (no feature/fix) |
| `docs` | Documentation only |
| `test` | Tests only |
| `chore` | Maintenance |
| `style` | Formatting |
| `perf` | Performance |

### Examples
```
feat(auth): add JWT token refresh
fix(api): handle null response
refactor(core): simplify validation logic
docs(readme): update installation steps
test(auth): add login edge cases
chore(deps): update Spring Boot to 4.0
```

## AI Attribution Rules

**NEVER include in commits/PRs:**
- `Co-authored-by: Claude`
- `Made by Claude/GPT/AI`
- `Generated by AI`
- `@anthropic.com` / `@openai.com`
- Model names (claude, gpt-4, etc.)

Git hooks automatically block these patterns.

## Release Process

### Prepare Release
```bash
git checkout develop
git pull

# Create release branch
git checkout -b release/v2.1.0

# Update version, changelog
# ...

git commit -m "chore(release): prepare v2.1.0"
git push -u origin release/v2.1.0
```

### Merge to Main
```bash
gh pr create --base main --title "Release v2.1.0"
# After approval:
gh pr merge --merge
```

### Tag Release
```bash
git checkout main
git pull
git tag -a v2.1.0 -m "Release v2.1.0"
git push origin v2.1.0
```

### Back-merge to Develop
```bash
git checkout develop
git merge main
git push
```

## Emergency Hotfix

```bash
# Branch from main
git checkout main
git checkout -b hotfix/critical-fix

# Fix and commit
git commit -m "fix(critical): description"

# PR directly to main
gh pr create --base main

# After merge, back-merge to develop
git checkout develop
git merge main
git push
```

## Useful Commands

```bash
# View branch status
git branch -vv

# Clean merged branches
git branch --merged develop | grep -v develop | xargs git branch -d

# Interactive rebase (before PR)
git rebase -i develop

# Amend last commit
git commit --amend

# Stash changes
git stash
git stash pop
```

## Pre-Push Checklist

1. ✅ Code formatted (`./gradlew spotlessApply`)
2. ✅ Tests pass locally
3. ✅ No AI attribution in commits
4. ✅ Commit messages follow convention
5. ✅ CI-Local passes (`./ci-local.sh full`)

## Related Skills

- `git-github`: GitHub CLI and API
- `devops-infra`: CI/CD integration
- `technical-docs`: Commit documentation

