git-workflow-patterns
Skill2 starsChanged 10 months agoMITView on GitHub
Git workflow patterns for team collaboration and release management. Use this skill when setting up branching strategies, writing commit messages, managing pull requests, resolving merge conflicts, or automating releases. Covers trunk-based development, Conventional Commits, rebasing strategies, and semantic versioning.
- Deletes or force-pushes
- Commits and pushes
We split this skill into the rules it gives an agent
11 rules. About 0 are common, 11 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈11
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 17
Clear history: - Commit messages explain why, not what.
- Distinctive: line 76
Use imperative mood ("add" not "added" or "adds")
- Distinctive: line 77
No period at the end of the subject
- Distinctive: line 119
Use draft PRs for work-in-progress
- Distinctive: line 121
Run CI checks before review
- Distinctive: line 152
When to use each:
- Distinctive: line 155
Squash merge: When feature branch has messy WIP commits
- Distinctive: line 156
Fast-forward: Only for trivial single-commit changes
- Distinctive: line 225
Keep branches short-lived (under 2 days)
- Distinctive: line 248
Commit signing: Use git config commit.gpgsign true without impacting speed
- Distinctive: line 249
Ref cleanup: Run git remote prune origin to remove stale remote branches
≈ “Common” is an estimate: at least 1 in 5 of the 308,232 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Git Workflow Patterns
Practical git workflow patterns for teams emphasizing clean history, safe collaboration, and reliable releases.
Core Principles
- Atomic commits - Each commit represents one logical change that compiles and passes tests
- Clear history - Commit messages explain why, not what; diffs explain what
- Branch hygiene - Short-lived feature branches, deleted after merge
- Linear history where possible - Rebase feature branches before merging to main
- Automate the boring parts - CI checks, changelog generation, version bumps
Branching Strategies
Use trunk-based development for most teams
# Create a short-lived feature branch from main
git checkout main
git pull origin main
git checkout -b feat/add-user-auth
# Work on the feature (keep branch lifetime under 2 days)
git add src/auth.py src/middleware.py
git commit -m "feat(auth): add JWT-based user authentication"
# Update from main before pushing
git fetch origin main
git rebase origin/main
git push -u origin feat/add-user-authKey strategy comparison:
- Trunk-based: Everyone commits to main (or short branches). Best for CI/CD and small teams.
- GitHub Flow: Feature branches + pull requests into main. Best for open source and mid-size teams.
- GitFlow: develop/release/hotfix branches. Best for scheduled releases with strict versioning.
See branching-strategies.md for:
- Detailed trunk-based development workflow
- GitHub Flow step-by-step
- GitFlow branch naming and lifecycle
- Release branch management
Commit Message Conventions
Follow Conventional Commits format
# Format: <type>(<scope>): <description>
#
# Types: feat, fix, docs, style, refactor, perf, test, build, ci, chore
# Breaking changes: add ! after type or BREAKING CHANGE in footer
git commit -m "feat(api): add pagination to /users endpoint"
git commit -m "fix(auth): prevent token refresh race condition"
git commit -m "docs(readme): update installation instructions"
# Breaking change
git commit -m "feat(api)!: change response format to JSON:API spec
BREAKING CHANGE: All API responses now follow JSON:API format.
Clients must update their parsers accordingly."Rules:
- Subject line under 72 characters
- Use imperative mood ("add" not "added" or "adds")
- No period at the end of the subject
- Blank line between subject and body
- Body explains why, not what
See commit-conventions.md for:
- Full Conventional Commits specification
- Semantic commit messages and changelog generation
- Squashing and fixup commit workflows
- Commit message templates
Pull Request Best Practices
Keep PRs small and focused on a single concern
# Create a PR with a structured description
gh pr create --title "feat(auth): add JWT authentication" --body "$(cat <<'EOF'
## Summary
- Add JWT token generation and validation
- Add authentication middleware for protected routes
- Add refresh token rotation
## Test Plan
- [ ] Unit tests for token generation/validation
- [ ] Integration tests for middleware
- [ ] Manual test: login flow end-to-end
## Related
Closes #142
EOF
)"
# Request specific reviewers
gh pr edit 155 --add-reviewer alice,bob
# Enable auto-merge after CI passes
gh pr merge 155 --auto --squashGuidelines:
- Target under 400 lines changed per PR
- One PR per feature or fix
- Use draft PRs for work-in-progress
- Require at least one approval before merge
- Run CI checks before review
See pr-best-practices.md for:
- PR description templates
- Review checklists and guidelines
- Draft PR workflows
- Auto-merge and CI integration
Rebasing vs Merging
Rebase feature branches, merge to main
# Rebase your feature branch onto latest main
git checkout feat/new-feature
git fetch origin main
git rebase origin/main
# If conflicts arise during rebase
# Fix each conflict, then continue
git add <resolved-files>
git rebase --continue
# Force-push rebased branch (only your own feature branch)
git push --force-with-lease origin feat/new-feature
# Merge to main with a merge commit (preserves branch context)
git checkout main
git merge --no-ff feat/new-featureWhen to use each:
- Rebase: Updating feature branch from main, cleaning up local commits
- Merge --no-ff: Integrating feature branch into main (preserves branch history)
- Squash merge: When feature branch has messy WIP commits
- Fast-forward: Only for trivial single-commit changes
See rebase-merge-patterns.md for:
- Interactive rebase for history cleanup
- Merge strategies and when to use each
- Handling rebase conflicts safely
- Squash merge workflows
Release Management
Use semantic versioning with automated changelogs
# Tag a release following semver
git tag -a v1.2.0 -m "Release v1.2.0: Add user authentication"
git push origin v1.2.0
# Create a GitHub release with auto-generated notes
gh release create v1.2.0 --generate-notes --title "v1.2.0"
# Hotfix workflow
git checkout -b hotfix/v1.2.1 v1.2.0
# ... apply fix ...
git commit -m "fix(auth): patch token expiry vulnerability"
git tag -a v1.2.1 -m "Hotfix v1.2.1: Patch token expiry"
git push origin hotfix/v1.2.1 --tagsVersioning rules (MAJOR.MINOR.PATCH):
- MAJOR: Breaking changes that require client updates
- MINOR: New features, backward compatible
- PATCH: Bug fixes, backward compatible
See release-management.md for:
- Semantic versioning deep dive
- Automated changelog generation
- GitHub Releases and CI/CD automation
- Release branch strategies
Merge Conflict Resolution
Resolve conflicts methodically, not hastily
# See which files have conflicts
git status
# Use a merge tool for complex conflicts
git mergetool
# For simple conflicts, edit manually
# Look for conflict markers:
# <<<<<<< HEAD
# (your changes)
# =======
# (incoming changes)
# >>>>>>> feat/other-branch
# After resolving all conflicts
git add <resolved-files>
git rebase --continue # if rebasing
git merge --continue # if merging
# Abort if things go wrong
git rebase --abort
git merge --abortPrevention strategies:
- Keep branches short-lived (under 2 days)
- Rebase frequently from main
- Communicate with teammates about shared files
- Break large changes into smaller PRs
Anti-Patterns
| Avoid | Use Instead |
git push --force on shared branches | git push --force-with-lease on your own branch |
| Long-lived feature branches (weeks) | Short-lived branches merged within 1-2 days |
| Merge commits from main into feature branch | git rebase origin/main |
| Vague commit messages ("fix stuff") | Conventional Commits ("fix(auth): resolve token expiry") |
| Giant PRs with 1000+ lines | Small focused PRs under 400 lines |
| Committing directly to main | Feature branches with PR review |
| Manual version bumps | Automated versioning from commit history |
| Resolving conflicts by accepting all theirs/ours | Reviewing each conflict individually |
Performance
- Shallow clones for CI:
git clone --depth 1speeds up CI pipelines - Sparse checkout:
git sparse-checkout set src/ tests/for monorepos - Git LFS: Track large binaries with
git lfs track "*.psd"to keep repo small - Commit signing: Use
git config commit.gpgsign truewithout impacting speed - Ref cleanup: Run
git remote prune originto remove stale remote branches - Garbage collection:
git gc --aggressivereclaims space in bloated repos - Partial clone:
git clone --filter=blob:nonefor faster initial clone of large repos - Fsmonitor: Enable
git config core.fsmonitor truefor faster status on large worktrees
source: Git workflow best practices for team collaboration
In this repository38 other files it gives its agents.
- Data Engineering Cloud InfrastructureSkill
- data-eng-data-qualitySkill
- data-eng-streaming-patternsSkill
- data-eng-testing-patternsSkill
- data-eng-warehouse-patternsSkill
- DevOps CI/CD PatternsSkill
- devops-docker-patternsSkill
- devops-monitoring-observabilitySkill
- devops-terraform-patternsSkill
- git-advanced-operationsSkill
- modern-python-patternsSkill
- python-api-developmentSkill
- python-async-patternsSkill
- python-data-pipelinesSkill
- python-data-wranglingSkill
- python-devops-automationSkill
- python-error-handlingSkill
- python-package-developmentSkill
- python-performanceSkill
- python-testingSkill
- customizing-vectors-rSkill
- designing-oop-rSkill
- developing-packages-rSkill
- metaprogramming-rlangSkill
- optimizing-rSkill
- writing-tidyverse-rSkill
- sql-advanced-featuresSkill
- sql-analytics-patternsSkill
- sql-data-modelingSkill
- SQL Integration PatternsSkill
- sql-query-fundamentalsSkill
- sql-query-optimizationSkill
- sql-transformationsSkill
- API DesignSkill
- webdev-html-css-patternsSkill
- webdev-javascript-fundamentalsSkill
- webdev-react-patternsSkill
- webdev-typescript-patternsSkill
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
Reviews can't be read right now.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

