git-workflow-assistant
Skill2 starsChanged 4 months agoMITView on GitHub
Guides Git operations safely — branching, rebasing, merge-conflict resolution, history rewriting, recovery of lost commits, bisecting bugs, and writing conventional commits and pull-request descriptions. Use when the user is stuck in a rebase or merge, wants to undo a commit, lost work, needs to clean up history before a PR, asks about reflog, cherry-pick, submodules, or how to write a commit message or changelog.
- Reads credentials
- Deletes or force-pushes
- Installs packages
- Commits and pushes
In this repository13 other files it gives its agents.
- AGENTS.mdAGENTS.md
- accessibility-auditorSkill
- contract-reviewerSkill
- csv-data-profilerSkill
- dependency-auditorSkill
- meeting-notes-to-actionsSkill
- prompt-engineering-optimizerSkill
- release-notes-generatorSkill
- rest-api-designerSkill
- security-code-reviewSkill
- sql-query-optimizerSkill
- technical-writing-editorSkill
- web-research-synthesizerSkill
The file
We split this skill into the rules it gives an agent
5 rules. About 0 are common, 3 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
2
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
- Very specific: line 32
Never suggest
git push --force: Use --force-with-lease, always. - Distinctive: line 33
Warn explicitly: before anything that rewrites shared history or discards uncommitted changes, and say precisely what will be lost.
- Distinctive: line 71
If the work was never committed, Git cannot help.
- Very specific: line 80
Verify: build and run tests before git add and --continue.
- Distinctive: line 137
Default recommendation: trunk-based, branches under 2 days, squash-merge to keep main linear and revertible.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 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 Assistant
Get the user unstuck without destroying work. Git rarely loses commits — people lose pointers to them.
When to use
Any Git question, especially the scary ones: "I think I deleted my work", "my rebase is broken", "I committed a secret", "I need to undo a push".
Hard rules
- Ask what state the repo is in before advising. Request
git status && git log --oneline -10 && git branch -vv— a wrong assumption here costs the user their work. - Create a safety net before any destructive command:
git branch backup/$(date +%Y%m%d-%H%M%S). - Never suggest
git push --force. Use--force-with-lease, always. - Warn explicitly before anything that rewrites shared history or discards uncommitted changes, and say precisely what will be lost.
- Committed work is recoverable for ~90 days via reflog. Say this first when someone panics — then recover it.
Decision table: "I want to undo…"
| Goal | Command | Destructive? |
| Unstage a file | git restore --staged <file> | No |
| Discard uncommitted changes to a file | git restore <file> | Yes — unrecoverable |
| Amend the last commit message | git commit --amend | Rewrites history if pushed |
| Add a forgotten file to the last commit | git add f && git commit --amend --no-edit | Same |
| Undo the last commit, keep changes staged | git reset --soft HEAD~1 | No |
| Undo the last commit, keep changes unstaged | git reset HEAD~1 | No |
| Undo the last commit, delete the changes | git reset --hard HEAD~1 | Yes — reflog can recover the commit |
| Undo a pushed commit | git revert <sha> | No — safest option on shared branches |
| Undo a pushed merge | git revert -m 1 <merge-sha> | No |
| Drop a commit from the middle | git rebase -i <sha>~1, delete the line | Rewrites history |
| Move commits to another branch | git cherry-pick <sha>… then reset the source | Rewrites the source |
| Recover a deleted branch | git reflog → git branch <name> <sha> | No |
| Recover from a bad rebase | git reflog → git reset --hard HEAD@{n} | Restores the pre-rebase state |
| Abort mid-operation | git rebase --abort / git merge --abort / git cherry-pick --abort | No |
| Stash including untracked | git stash push -u -m "wip" | No |
| Find which commit broke something | git bisect start / bad / good | No |
| Find who changed a line | git log -L <start>,<end>:<file> or git blame -w -C | No |
Recovering lost work
git reflog --date=iso | head -40 # every HEAD position, ~90 days
git fsck --lost-found # dangling commits and blobs
git stash list # stashes are easy to forget
git reflog show <branch> # per-branch historyThen: git branch recovered <sha> — inspect before resetting anything.
If the work was never committed, Git cannot help. Check the editor's local history (JetBrains "Local History", VS Code timeline) and say so honestly.
Merge conflicts
git status— list conflicted files; understand why both sides changed.- Resolve per file. Never blindly
--ours/--theirson a file you have not read. - Reuse recorded resolutions on repeats:
git config rerere.enabled true. - For a 3-way view:
git checkout --conflict=diff3 <file>shows the common ancestor. - Verify: build and run tests before
git addand--continue. - During a rebase, "ours" and "theirs" are inverted relative to a merge —
--oursis the upstream branch. State this explicitly; it causes real damage.
Reduce conflicts structurally: smaller PRs, rebase on the target branch daily,
agree on formatter config, and add a .gitattributes merge=union for changelogs.
Committed a secret
Rotating the credential is step one and is non-negotiable — assume it is compromised the moment it is pushed. Then rewrite history:
pip install git-filter-repo
git filter-repo --invert-paths --path secrets.env # or --replace-text
git push --force-with-lease --all
git push --force-with-lease --tagsThen: everyone re-clones (do not merge old clones back), and ask the host to
expire cached views of the old objects. git rm alone does not remove it
from history.
Commit messages and PRs
Conventional Commits:
<type>(<scope>): <imperative summary, <= 72 chars>
Why this change is needed, and what the reader cannot infer from the diff.
BREAKING CHANGE: <what breaks and how to migrate>
Refs: #123Types: feat, fix, docs, style, refactor, perf, test, build,
ci, chore, revert.
Rules: imperative mood ("add", not "added"); explain why, the diff already
shows what; one logical change per commit; never "fix stuff" or "wip" on main.
Generate a message from the staged diff:
git diff --cached | python3 scripts/commit_helper.py --style conventionalBranching models
| Model | Fits | Cost |
| Trunk-based + short-lived branches | Continuous deployment, strong CI | Requires feature flags |
| GitHub Flow | Web apps, one production version | Weak for multiple supported releases |
| Git Flow | Versioned/on-prem releases | Heavy; frequent merge pain |
| Release branches off trunk | Mobile, SDKs | Backport discipline needed |
Default recommendation: trunk-based, branches under 2 days, squash-merge to keep
main linear and revertible.
Worked example
"I rebased onto main and now my last three commits are gone."
Step 1 — reassure and snapshot
git reflog --date=iso | head -20a1b2c3d HEAD@{0}: rebase (finish): returning to refs/heads/feature
9f8e7d6 HEAD@{4}: commit: add retry logic <- the workStep 2 — recover without touching the current branch
git branch recovered 9f8e7d6
git log --oneline main..recovered # confirm the three commits are thereStep 3 — reapply
git checkout feature
git cherry-pick <sha1> <sha2> <sha3> # or: git reset --hard recoveredCause: the rebase hit a conflict, and git rebase --skip was used instead of
resolving — skipping drops the commit. Next time use --abort when unsure.
Quality checklist
- Current repo state established before advising
- Backup branch created before any destructive command
--force-with-leaseused, never bare--force- Every command explained in one line, so the user learns
- Consequences for collaborators on shared branches stated
- Recovery path given for anything irreversible
- Secret exposure → rotation advised before history rewriting
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.

