git-workflow
Skill11 starsChanged 6 months agoMITView on GitHub
Guides safe, professional Git usage — branching strategies, atomic clean commits, conventional commit messages, interactive rebase (squash/fixup/reword/reorder), merge vs rebase decisions, conflict resolution, and recovery of lost work via reflog. Use this skill when the user asks to create or clean up a branch, write or amend commits, squash or reorder history, rebase onto main, resolve merge conflicts, undo a bad commit/merge/reset, recover deleted commits or branches, find lost work, fix a detached HEAD, force-push safely, or generally "clean up my git history" before opening a PR.
- Deletes or force-pushes
- Commits and pushes
118 other projects use a version of this.
Adopted by
Most recently taken up by
- Lukk17/agent-standardstheir own version, first seen Oct 5, 2026
- JameMy0001/antigravity-skills-hubtheir own version, first seen Oct 2, 2026
- NinjaSln-labs/agent-skillstheir own version, first seen Oct 2, 2026
- 1pedroosilva/databricks-genie-skillstheir own version, first seen Oct 2, 2026
- vospr/context-engineering-templatetheir own version, first seen Oct 1, 2026
- fusebase-dev/fusebase-flowtheir own version, first seen Oct 1, 2026
Used with
Projects with it also use squad-commands, typescript-patterns and 10 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.
MicrosoftSkillsquad-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 3 projects that use this
cohen-lielSkilltypescript-patterns
TypeScript best practices and patterns. Use when writing TypeScript code, defining types, working with generics, or converting JavaScript to TypeScript.
Also in 4 projects that use this
martinholovskySkillllm-integration
Expert skill for integrating local Large Language Models using llama.cpp and Ollama. Covers secure model loading, inference optimization, prompt handling, and protection against LLM-specific vulnerabilities including prompt injection, model theft, and denial of service attacks.
Also in 4 projects that use this
MicrosoftSkillcost-optimization
Optimize existing Azure resources and analyze Reservations or Savings Plans. WHEN: \"optimize Azure costs\", \"reduce cloud spending\", \"rightsize resources\", \"find idle resources\", \"orphaned disk\", \"deleted VM still charged\", \"public IP still charging\", \"reservation utilization\", \"Savings Plan coverage\", \"commitment recommendation\", \"why is pay-as-you-go still charged\". DO NOT USE FOR: cost spikes, forecasts, pricing estimates, budgets, or governance.
Also in 5 projects that use this
YepAPISkillbackground-jobs
Queue workers with BullMQ/Inngest/Trigger.dev, job retries, dead letter queues, concurrency.
Also in 3 projects that use this
Vimalk0703Skilldependency-management
Vet packages before adoption, audit for vulnerabilities, pin versions, and prevent dependency bloat.
Also in 3 projects that use this
- +1 more from microsoft
Other versions118 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 118
- JetBrains/ideavim★ 10ksame name
- Galaxy-Dawn/claude-scholar★ 5.7ksame name
- github/gh-aw★ 5.3ksame name
- microsoft/Generative-AI-for-beginners-dotnet★ 3.1ksame name
- microsoft/waza★ 1.4ksame name
- laolaoshiren/claude-code-skills-zh★ 876same name
- Mindrally/skills★ 266same name
- Azure/fleet★ 226same name
- povvo/claudikins-kernel★ 128same name
- extra-org/extra★ 113same name
108 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 repository74 other files it gives its agents.
- 0-templateSkill
- ab-test-analyzerSkill
- adr-authorSkill
- api-designerSkill
- api-docs-writerSkill
- aws-cost-optimizerSkill
- bash-script-hardeningSkill
- blog-post-writerSkill
- book-summarizerSkill
- changelog-keeperSkill
- chart-chooserSkill
- code-reviewerSkill
- competitive-analysisSkill
- concept-explainerSkill
- cover-letter-writerSkill
- cron-schedulerSkill
- data-pipeline-architectSkill
- debug-detectiveSkill
- decision-matrixSkill
- dependency-upgraderSkill
- dockerfile-proSkill
- email-composerSkill
- error-handling-patternsSkill
- event-plannerSkill
- flashcard-generatorSkill
- gdpr-data-mapperSkill
- gift-advisorSkill
- github-actions-builderSkill
- habit-builderSkill
- incident-postmortemSkill
- interview-prepSkill
- job-description-writerSkill
- json-schema-authorSkill
- kubernetes-manifest-authorSkill
- language-tutorSkill
- meal-plan-builderSkill
- meeting-summarizerSkill
- mermaid-diagram-builderSkill
- nginx-config-proSkill
- observability-setupSkill
- okr-writerSkill
- pandas-data-cleaningSkill
- performance-profilerSkill
- personal-budget-plannerSkill
- presentation-builderSkill
- project-plannerSkill
- prompt-engineerSkill
- proofreaderSkill
- public-speaking-coachSkill
- rag-pipeline-designerSkill
- readme-generatorSkill
- refactoring-guideSkill
- regex-architectSkill
- release-notes-writerSkill
- resume-writerSkill
- salary-negotiatorSkill
- secrets-managerSkill
- secure-code-reviewSkill
- secure-password-policySkill
- security-auditorSkill
- The first 60 shown.
The file
Show its rules and text
We split this skill into the rules it gives an agent
14 rules. 0 are common, 5 are distinctive, and 9 are very specific to this project.
0
Common
Most of the 101 edited versions we read keep these.
5
Distinctive
This author's own choices. Worth a look.
9
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 16
Never rewrite history that others have already pulled (shared branches like main/develop).
- Very specific: line 17
Before any rebase, reset --hard, or force-push, note the current commit: git rev-parse HEAD or just trust the reflog — it remembers.
- Very specific: line 18
Prefer git push --force-with-lease over --force.
- Distinctive: line 19
Commit early, commit often locally.
- Very specific: line 20
If something looks lost, it almost certainly isn't — go to git reflog (see references/reflog-recovery.md).
- Distinctive: line 25
Always understand current state first:
- Very specific: line 33
Update the base first: git switch main && git pull --ff-only.
- Very specific: line 34
Create the branch: git switch -c feat/short-description.
- Very specific: line 39
Write a Conventional Commit message (see references/conventional-commits.md):
- Distinctive: line 45
Verify before committing: re-read git diff --staged.
- Very specific: line 62
When a rebase/merge stops on a conflict, follow the step-by-step protocol in references/conflict-resolution.md.
- Very specific: line 130
Run scripts/rebase-safety-check.sh after a rebase to confirm no commits were silently dropped and the tree still matches expectations.
- Distinctive: line 131
Use git add -p to keep commits atomic instead of git add ..
- Distinctive: line 132
Prefer git switch/git restore over the overloaded git checkout.
“Common” is measured: kept by at least 6 in 10 of the 101 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
Overview
This skill provides a disciplined, safe workflow for everyday Git: branching, crafting clean atomic commits, rewriting history with interactive rebase, resolving conflicts, and recovering from mistakes using the reflog. The guiding principle is safety first — never destroy work you cannot recover, always know your escape hatch before running a history-rewriting command.
Keywords: git, branch, commit, rebase, interactive rebase, squash, fixup, reword, cherry-pick, merge, conflict, conflict resolution, reflog, recover lost commits, undo, reset, revert, detached HEAD, force-push, stash, clean history, conventional commits, PR prep.
Golden rules
- Never rewrite history that others have already pulled (shared branches like
main/develop). Rewrite only your own unmerged feature branches. - Before any
rebase,reset --hard, or force-push, note the current commit:git rev-parse HEADor just trust the reflog — it remembers. - Prefer
git push --force-with-leaseover--force. It refuses to clobber commits you haven't seen. - Commit early, commit often locally; clean up into atomic commits before sharing.
- If something looks lost, it almost certainly isn't — go to
git reflog(see references/reflog-recovery.md).
Workflow
1. Orient before acting
Always understand current state first:
git status # working tree + branch
git log --oneline -10 # recent history
git branch -vv # branches + tracking2. Branch
- Update the base first:
git switch main && git pull --ff-only. - Create the branch:
git switch -c feat/short-description. - Naming:
<type>/<slug>e.g.feat/oauth-login,fix/null-deref,chore/bump-deps,docs/readme. See references/branch-naming.md.
3. Make atomic commits
- One logical change per commit. Stage selectively:
git add -pto split a working tree into focused hunks. - Write a Conventional Commit message (see references/conventional-commits.md):
feat(auth): add OAuth2 PKCE login flow Body explaining WHY, wrapped at ~72 cols. Reference issues. - Verify before committing: re-read
git diff --staged.
4. Keep up to date with the base
Choose merge vs rebase intentionally (see decision framework below). For a private feature branch, rebasing keeps history linear:
git fetch origin
git rebase origin/main5. Clean up history before opening a PR
Squash noise ("wip", "fix typo"), reword unclear messages, reorder for logical flow:
git rebase -i origin/mainFull guidance and the command cheat sheet: references/interactive-rebase.md. Validate the result before pushing: scripts/rebase-safety-check.sh.
6. Resolve conflicts methodically
When a rebase/merge stops on a conflict, follow the step-by-step protocol in references/conflict-resolution.md. Summary:
git status # see conflicted files
# edit files, remove <<<<<<< ======= >>>>>>> markers
git add <resolved-files>
git rebase --continue # or: git merge --continue
# abort anytime: git rebase --abort / git merge --abort7. Share
git push -u origin feat/short-description # first push
git push --force-with-lease # after a rebase/amend8. Recover when things go wrong
Nothing is lost until garbage collection runs (default ~30–90 days). See references/reflog-recovery.md and run scripts/git-recover.sh to surface candidate lost commits.
Decision Framework: Merge vs Rebase
| Situation | Use |
Updating your private, unpushed feature branch with latest main | git rebase origin/main (linear history) |
| Branch is shared / others have it checked out | git merge origin/main (don't rewrite shared history) |
Combining a finished feature into main (team prefers linear) | rebase then fast-forward / squash-merge |
| Combining a feature, preserving full context & merge point | git merge --no-ff |
| You just want to grab one commit from another branch | git cherry-pick <sha> |
Rule of thumb: rebase local, merge shared.
Interactive Rebase Quick Reference
In the git rebase -i todo list, set the action keyword on each line:
| Keyword | Effect |
pick | keep the commit as-is |
reword (r) | keep changes, edit the message |
edit (e) | stop to amend the commit (split, add files) |
squash (s) | merge into previous commit, combine messages |
fixup (f) | merge into previous commit, discard this message |
drop (d) | remove the commit entirely |
| reorder | move lines up/down to reorder commits |
Targeted fixup workflow (best for PR review fixes):
git commit --fixup=<sha> # creates "fixup! ..." commit
git rebase -i --autosquash origin/main # auto-positions & marks it fixupRecovery Cheat Sheet
| Problem | Fix |
| Bad last commit, want to redo message | git commit --amend |
| Undo last commit, keep changes staged | git reset --soft HEAD~1 |
| Undo last commit, keep changes unstaged | git reset HEAD~1 |
| Discard last commit AND its changes | git reset --hard HEAD~1 (recoverable via reflog) |
| Revert a commit already pushed/shared | git revert <sha> (new commit, safe) |
| Lost commits after bad reset/rebase | git reflog then git reset --hard <sha> |
| Deleted a branch by accident | git reflog → find tip sha → git branch <name> <sha> |
| Detached HEAD with work to keep | git switch -c rescue-branch immediately |
Accidentally committed to main | branch it off, then reset main: see references/reflog-recovery.md |
| Drop unstaged local changes | git restore <file> / git restore . |
| Stash WIP to switch context | git stash push -m "msg" → git stash pop |
Best Practices
- Make the first line of a commit ≤ 50 chars, imperative mood ("add", not "added").
- Run
scripts/rebase-safety-check.shafter a rebase to confirm no commits were silently dropped and the tree still matches expectations. - Use
git add -pto keep commits atomic instead ofgit add .. - Prefer
git switch/git restoreover the overloadedgit checkout. - Tag the pre-rebase state if nervous:
git tag backup-before-rebase. Delete it when done. - Configure
git config rerere.enabled trueto let Git remember conflict resolutions across repeated rebases.
Common Pitfalls
- Force-pushing a shared branch and erasing teammates' commits. Use
--force-with-lease, and never onmain. - Rebasing
main/develop— rewriting public history breaks everyone. Userevertinstead. git reset --hardwithout checking — you lose uncommitted working-tree changes permanently (these are NOT in the reflog). Stash first.- Resolving a conflict by deleting the wrong side — read both sides; the markers are
<<<<<<< HEAD(current/your side during merge) vs>>>>>>> branch(incoming). During rebase the sides are swapped — see references/conflict-resolution.md. - Committing generated files / secrets — review
git diff --staged; use.gitignore. - Assuming work is gone after a botched rebase — check
git reflogbefore doing anything else.
Bundled Files
references/interactive-rebase.md— complete interactive rebase guide with worked scenarios.references/conflict-resolution.md— step-by-step conflict protocol, marker semantics, rerere, tools.references/reflog-recovery.md— recover lost commits, branches, resets, detached HEAD, wrong-branch commits.references/conventional-commits.md— message format, types, scopes, breaking changes, examples.references/branch-naming.md— naming conventions and branching models.scripts/git-recover.sh— list recently dangling/unreachable commits with previews to aid recovery.scripts/rebase-safety-check.sh— sanity-check history after a rebase against the upstream base.examples/squash-feature-branch.md— end-to-end worked example of cleaning a messy branch.
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.

