git-workflow
Skill8 starsChanged 9 days agoMITView on GitHub
Uses Git safely and cleanly - atomic commits with clear messages, branching, rebase vs merge, conflict resolution, pull request descriptions, and recovering from mistakes such as lost commits, bad merges, commits on the wrong branch, or a committed secret. Use when committing, writing commit messages, branching, rebasing, merging, resolving conflicts, preparing a pull request, undoing changes, cleaning history, or when someone says they broke their repository.
- Reads credentials
- Deletes or force-pushes
- Commits and pushes
188 other projects use a version of this.
Adopted by
Most recently taken up by
- Rojios/everything-claude-codetheir own version, first seen Nov 8, 2026
- kinhluan/skillstheir own version, first seen Nov 8, 2026
- juninmd/skillstheir own version, first seen Nov 8, 2026
- jDxve/avengers-kittheir own version, first seen Nov 8, 2026
- lhbsaa/apex-unifiedtheir own version, first seen Nov 8, 2026
- haythamasalama/skillstheir own version, first seen Nov 8, 2026
Used with
Projects with it also use squad-commands, architectural-proposals and 9 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
Microsoft AzureSkillsquad-commands
Categorized catalog of common Squad operations. Coordinator reads this file and presents it as an interactive menu when the user asks for available commands or help.
Also in 5 projects that use this
Microsoft AzureSkillarchitectural-proposals
How to write comprehensive architectural proposals that drive alignment before code is written
Also in 4 projects that use this
GitHubSkille2e-template-testing
End-to-end validation of coordinator and agent template changes
Also in 3 projects that use this
GitHubSkillnotification-routing
Route agent notifications to specific channels by type — prevent alert fatigue from single-channel flooding
Also in 3 projects that use this
frostneySkillnative-nostalgia-stack
Applies the user's FreePascal toolchain and its build, formatting, hook, and test contracts while leaving project-specific mechanics local. Use when scaffolding or working in a FreePascal project that follows this toolchain.
Also in 3 projects that use this
- +5 more from Azure
- +1 more from github
Other versions188 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 188
- langfuse/langfuse★ 37ksame name
- modelcontextprotocol/typescript-sdk★ 14ksame name
- JetBrains/ideavim★ 10ksame name
- jokob-sk/NetAlertX★ 7.4ksame name
- netalertx/NetAlertX★ 7.4ksame name
- Galaxy-Dawn/claude-scholar★ 5.9ksame name
- github/gh-aw★ 5.6ksame name
- modelcontextprotocol/csharp-sdk★ 4.6ksame name
- antonbabenko/pre-commit-terraform★ 3.8ksame name
- github/squad★ 3.4ksame name
178 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository60 other files it gives its agents.
- api-designSkill
- auth-implementationSkill
- background-jobsSkill
- building-agentsSkill
- caching-strategiesSkill
- ci-cd-pipelinesSkill
- cloud-cost-optimizationSkill
- codebase-onboardingSkill
- code-review-changesSkill
- concurrency-patternsSkill
- database-migrationsSkill
- database-schema-designSkill
- database-testingSkill
- data-pipelinesSkill
- data-privacy-retentionSkill
- dependency-upgradesSkill
- design-docsSkill
- design-systemsSkill
- dockerfilesSkill
- domain-driven-designSkill
- event-driven-architectureSkill
- file-storage-uploadsSkill
- frontend-securitySkill
- graphql-apisSkill
- grpc-servicesSkill
- incident-responseSkill
- infrastructure-as-codeSkill
- internationalizationSkill
- kubernetes-deploymentsSkill
- large-scale-migrationsSkill
- legacy-refactoringSkill
- llm-evalsSkill
- llm-integrationSkill
- mcp-serversSkill
- micro-frontendsSkill
- ml-experimentsSkill
- monorepo-managementSkill
- nosql-designSkill
- observabilitySkill
- orm-patternsSkill
- performance-profilingSkill
- postgres-operationsSkill
- rag-systemsSkill
- react-patternsSkill
- realtime-apisSkill
- resilience-patternsSkill
- root-cause-debuggingSkill
- search-integrationSkill
- security-auditSkill
- seo-and-ssrSkill
- sql-optimizationSkill
- system-designSkill
- test-strategySkill
- threat-modelingSkill
- typescript-patternsSkill
- unit-testingSkill
- verify-before-doneSkill
- web-accessibilitySkill
- web-performanceSkill
- writing-skillsSkill
The file
We split this skill into the rules it gives an agent
12 rules. 0 are common, 7 are distinctive, and 5 are very specific to this project.
0
Common
Most of the 165 edited versions we read keep these.
7
Distinctive
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Distinctive: line 13
Stop and get explicit confirmation from the user before running any of these.
- Distinctive: line 26
Before a risky operation:
- Distinctive: line 28
Run git status and git stash list and read the output.
- Very specific: line 29
Create a backup ref: git branch backup/before-rebase (any clear name).
- Very specific: line 30
Prefer the safer variant: --force-with-lease over --force, git reset --keep over --hard, git revert over rewriting pushed history.
- Distinctive: line 51
Follow the repository's convention first: Check git log --oneline -20 and any commitlint or contributing config.
- Very specific: line 52
Do not commit build output, dependencies, local environment files or editor folders.
- Distinctive: line 84
Remove every conflict marker.
- Very specific: line 114
Do not commit large binaries or datasets.
- Very specific: line 126
Not pushed yet: remove the secret from the files, move it to environment variables or a secret manager, add the file to .gitignore, and …
- Distinctive: line 143
No secrets, generated files or unrelated changes were committed.
- Distinctive: line 145
Every destructive or outward-facing command was confirmed by the user, with a backup ref in place first.
“Common” is measured: kept by at least 6 in 10 of the 165 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Git Workflow
History is shared infrastructure. Keep commits small and explainable, never rewrite history other people have pulled, and know how you will get back (the reflog, a backup branch) before running anything destructive.
Safety rules
Stop and get explicit confirmation from the user before running any of these. Say exactly what could be lost.
| Command | Risk |
git push --force / --force-with-lease | Rewrites the remote branch; others' commits can be lost |
git reset --hard | Permanently discards uncommitted changes |
git clean -fd (or -fdx) | Permanently deletes untracked (and ignored) files |
git restore <path> / git checkout -- <path> | Permanently discards uncommitted changes in those files |
git branch -D / git push origin --delete <branch> | Deletes a branch; the remote one may be unrecoverable for you |
git stash drop / git stash clear | Removes stash entries (recovery is possible but awkward) |
git rebase on a branch others use | Rewrites shared history |
git filter-repo or any history rewrite | Changes every affected commit ID; all clones must be reset |
Before a risky operation:
- Run
git statusandgit stash listand read the output. - Create a backup ref:
git branch backup/before-rebase(any clear name). - Prefer the safer variant:
--force-with-leaseover--force,git reset --keepover--hard,git revertover rewriting pushed history.
Also: never skip hooks with --no-verify unless the user asks, and never push, open pull requests or delete remote branches unless the user asked for it.
Commits
- One logical change per commit. Each commit should build and pass tests, so
git bisectandgit revertwork cleanly. - Stage deliberately. Name the files:
git add src/orders/refund.ts tests/refund.test.ts. Avoidgit add ./git add -Aunless you have readgit statusand every change belongs in the commit. (git add -pstages parts of files but is interactive; use it only in an interactive terminal.) - Review what you are committing:
git diff --cached. Look for secrets, debug output, generated files and unrelated changes. - Write the message:
<summary: imperative mood, about 50 chars, at most 72>
<body: what changed and why, not how. Wrap at 72. Mention
trade-offs, alternatives rejected, and anything surprising.>
<footer: Refs #123, Co-authored-by: ..., BREAKING CHANGE: ...>- Imperative summary: "Add retry with backoff to payment client", not "Added retries" or "fix stuff".
- Follow the repository's convention first. Check
git log --oneline -20and any commitlint or contributing config. If the project uses Conventional Commits, use its types:feat,fix,docs,refactor,perf,test,build,ci,chore, with!or aBREAKING CHANGE:footer for breaking changes. - Do not commit build output, dependencies, local environment files or editor folders; check
.gitignorecovers them.
Branching
| Model | Fits | Rules |
| Trunk-based (short-lived branches, feature flags) | Continuous delivery, most product teams | Branches live hours to a couple of days; main is always releasable; unfinished work hides behind flags |
| Feature branch + pull request to main (GitHub flow) | Most web and service projects | Same as above, with review on every PR; deploy from main |
| Release branches (and Gitflow-style models) | Several supported versions, scheduled releases, mobile or on-premises software | Fixes land on main and are cherry-picked to release branches (or the reverse, consistently); more merge overhead |
Name branches the way the repository already does (for example feat/refund-retries, fix/1234-null-org).
Rebase or merge
| Situation | Do this |
| Update your own, unshared feature branch with main | git fetch origin then git rebase origin/main (or git merge origin/main if the team prefers merge commits) |
| The branch is shared or others build on it | Merge (git merge origin/main); do not rebase |
| Tidy your own commits before review | Make fixup commits with git commit --fixup <sha>, then GIT_SEQUENCE_EDITOR=: git rebase -i --autosquash origin/main (the empty editor accepts the generated plan non-interactively). Or git reset --soft origin/main and recommit in clean steps. |
| Push after rebasing your own branch | git push --force-with-lease --force-if-includes (Git 2.30+), after confirmation |
| Integrate a PR into main | Use the repository's setting: squash merge, rebase merge or merge commit. Do not change it per PR without agreement. |
--force-with-lease refuses to overwrite the remote branch if it moved since your last fetch. A background fetch (from an editor, for example) can defeat it, which is what --force-if-includes guards against.
Resolving conflicts
git statuslists the conflicted files.- Understand both sides before editing:
git diffshows the conflict hunks.git log --merge -p -- <file>shows the commits on each side that touched the file.- During a merge, "ours" is your current branch and "theirs" is the branch being merged in. During a rebase, it is reversed: "ours" is the branch you are rebasing onto, and "theirs" is your commit being replayed.
- Resolve by intent: keep both changes when both are needed. Never take one side wholesale without reading the other.
- Remove every conflict marker.
git diff --checkreports leftover markers and whitespace errors. - Lockfiles (
package-lock.json,pnpm-lock.yaml,poetry.lock,Cargo.lock, ...): do not hand-merge. Take one side, then rerun the package manager so it regenerates the lockfile from the merged manifest. - Build and run the tests before continuing.
git add <file>, thengit rebase --continueorgit merge --continue. To back out completely:git rebase --abortorgit merge --abort.
For conflicts that keep recurring (long-running branches, repeated rebases), enable git config rerere.enabled true so Git reuses recorded resolutions.
Pull request descriptions
Self-review the full diff first (git diff origin/main...HEAD). Keep PRs small: under about 400 lines of logic is reviewable in one sitting. Then describe it:
## What
One or two sentences on the change.
## Why
The problem, with a link to the issue.
## How
Notable decisions and alternatives considered.
## Testing
Commands run, manual steps, screenshots or recordings for UI changes.
## Risk and rollout
Migrations, feature flags, backward compatibility, how to roll back.Large files
- Do not commit large binaries or datasets. Use Git LFS (
git lfs track "*.psd", then commit.gitattributes) or an artifact store. - To find large objects in history (POSIX shell):
git rev-list --objects --all \
| git cat-file --batch-check='%(objecttype) %(objectname) %(objectsize) %(rest)' \
| awk '$1 == "blob"' | sort -k3 -n | tail -20A secret was committed
- Treat the secret as compromised as soon as it was pushed, even if it was removed a minute later: clones, forks, CI logs and caches may have it. Rotate or revoke it first. That is the real fix. Tell the user immediately.
- Not pushed yet: remove the secret from the files, move it to environment variables or a secret manager, add the file to
.gitignore, and amend or redo the commit (git reset --soft HEAD~1, fix, recommit). - Already pushed: after rotating, decide with the user whether to rewrite history with
git filter-repo(notgit filter-branch). This needs a force-push and every collaborator must re-clone or reset. Hosting platforms may keep old commits reachable (pull request refs, caches); their support or docs describe how to purge them. Recipes are in references/recovery-recipes.md. - Prevent the next one: a secret scanner in pre-commit and CI (for example gitleaks or trufflehog), and the hosting platform's push protection if available.
Anti-patterns
- Messages like "WIP", "fix", "updates"; commits mixing refactoring, features and formatting.
- Rebasing or force-pushing shared branches, especially main.
git add .without readinggit status, committing.envfiles and build output.- Resolving conflicts by accepting one side everywhere.
- Branches that live for weeks and then cannot be merged.
- Deleting and re-cloning the repository instead of using the reflog.
- Rewriting history to "remove" a leaked secret without rotating it.
Done when
- Each commit is one logical change, builds, and has a clear imperative message that follows the repository's convention.
- No secrets, generated files or unrelated changes were committed.
- Conflicts are resolved with tests passing and no markers left.
- Every destructive or outward-facing command was confirmed by the user, with a backup ref in place first.
References
- references/recovery-recipes.md — read when something went wrong: undoing commits, recovering lost work, fixing commits on the wrong branch, reverting merges, or rewriting history to remove a secret or large file.
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.

