git-patterns
Skill2 starsChanged 7 days agoMITView on GitHub
Git workflow patterns covering Conventional Commits, interactive rebase, branch strategy, recovery with reflog, bisect, worktrees, and stash. Use whenever the project is a git repository (a `.git` directory present), OR the task involves a git operation (commit, branch, rebase, bisect, merge conflict, or recovering lost history), even if "git" is not mentioned by name.
- Reads credentials
- Deletes or force-pushes
In this repository37 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- templates/CLAUDE.mdCLAUDE.md
- auditSkill
- backup-patternsSkill
- bash-patternsSkill
- depsSkill
- django-patternsSkill
- docker-patternsSkill
- drf-patternsSkill
- engineering-fundamentalsSkill
- fastapi-patternsSkill
- go-patternsSkill
- graphql-patternsSkill
- investigateSkill
- javascript-patternsSkill
- logging-patternsSkill
- referenceSkill
- metaSkill
- monitoring-patternsSkill
- next-app-router-patternsSkill
- nuxt-patternsSkill
- opentofu-patternsSkill
- prSkill
- python-patternsSkill
- react-patternsSkill
- report-formatSkill
- security-patternsSkill
- slop-patternsSkill
- storybook-patternsSkill
- tailwind-patternsSkill
- test-patternsSkill
- typescript-patternsSkill
- unslopSkill
- vps-provisioningSkill
- vue-patternsSkill
- wcag-auditSkill
- writeSkill
The file
Files
Git Patterns
Review checklist and the handful of git behaviors that are easy to get wrong. Command syntax is in the man pages; this file is what to flag and what to reach for.
Conventional Commits
<type>[optional scope]: <description>
[optional body]
[optional footer(s)]featbumps MINOR,fixbumps PATCH, everything else (docs,style,refactor,perf,test,chore,ci) bumps nothing.- Breaking change:
!after the type/scope, or aBREAKING CHANGE:footer. Either maps to MAJOR. - Match the project's existing style before assuming Conventional Commits (
rules/workflow.md).
Reach for these
| Situation | Tool |
| Commits lost after a bad rebase or reset | git reflog: every HEAD move is recorded; branch off HEAD@{n} |
| Need each commit in a series to build | exec lines in the rebase -i todo (exec make test) |
| Hunting the commit that broke something | git bisect run <cmd>: automates the whole search; exit 0 = good |
| Reviewing a branch mid-edit on another | git worktree add <dir> <branch>: separate working tree, shared .git |
| Fixups for already-staged hunks | git absorb (see rules/tooling.md) beats hand-written rebase -i |
| A file is ignored and you cannot see why | git check-ignore -v <path> names the rule and its source line |
Anti-patterns
failure: force-pushing to a shared branch
The rule is rules/workflow.md section 1. To force-push your own remote branch, use --force-with-lease --force-if-includes: the first fails if someone else pushed since your last fetch, the second also fails when a background fetch updated the ref without you seeing it.
failure: committing secrets
git rm does not remove it from history; the secret is still in every clone. Remediation is rotation: security-patterns' reference/secrets.md.
warning: merge commit spam on feature branches
Merging main into a feature branch repeatedly to stay up to date produces a messy history. Prefer git rebase main on the feature branch to keep a linear history before merge.
warning: squashing a merge commit into a feature commit
Interactive rebase cannot squash across a merge commit. Resolve by rebasing onto main first to linearize history, then squash.
warning: committing with --no-verify
Skipping pre-commit hooks bypasses linting, type checks, and secret scanning. Only use if you understand exactly which hook is blocking you and why it is safe to skip in that moment.
warning: git reset --hard as a routine undo
It discards working tree changes with no reflog entry for them. git reset --soft HEAD~1 keeps the changes staged and is the right default.
info: no .gitignore for secrets patterns
An .env or *.key file not listed in .gitignore will eventually be committed by accident. Add secret file patterns before any other work in a new repo.
References
- https://www.conventionalcommits.org/en/v1.0.0/
- https://git-scm.com/docs/git-rebase
- https://git-scm.com/docs/git-reflog
- https://git-scm.com/docs/git-bisect
- https://git-scm.com/docs/git-worktree
- https://git-scm.com/docs/git-push
- https://git-scm.com/docs/git-switch
Version notes
Checked: 2026-09-26 against https://git-scm.com, https://github.com/git/git/blob/master/Documentation/RelNotes/2.30.0.adoc and https://www.conventionalcommits.org/en/v1.0.0/
- git 2.55.0 (2026-06-29): no guidance change.
git switch/git restoreare the documented replacements for branch and filecheckout;checkoutstill works. --force-if-includes(2.30+): pairs with--force-with-leaseagainst the background-fetch gap; added to the force-push guidance 2026-09-12.- Conventional Commits spec is 1.0.0; unchanged.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
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.

