agentsclimarketplace

Git rewriting history

Skill narenaryan/agent-skills/skills/git/git-rewriting-history

Byte-sized agent skills for giving advanced knowledge to AI agents

Install
npx -y skills add narenaryan/agent-skills --skill git-rewriting-history

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its author says it does

Copied from the file, not written here

Use when editing past commits — amending, splitting, squashing, reordering, dropping, or bulk-rewriting history with interactive rebase or filter-repo

SKILL.md

1.9 KB, 476 tokens by cl100k_base, as published. Nobody here has run it

Rewriting Git History

Iron rule: only rewrite commits not yet pushed to a shared branch. Every rewrite changes the SHA of the commit and all descendants.

Amend

git commit --amend              # edit message + staged changes
git commit --amend --no-edit    # fold staged changes, keep message
git commit --amend --author="Name <email>"

Interactive Rebase

git rebase -i HEAD~N
git rebase -i --root
git rebase -i --autosquash      # auto-order fixup!/squash! commits

Commits appear oldest-first (replay order, opposite of git log).

VerbEffect
pickuse as-is
rewordkeep diff, edit message
editstop to amend diff/message
squashfold into previous, combine messages
fixuplike squash, discard this message
dropremove entirely
exec <cmd>run cmd between commits (e.g. exec make test)

Splitting

Mark edit, then at the stop:

git reset HEAD^
git add -p && git commit
git rebase --continue

Bulk Rewrite: filter-repo

Prefer git-filter-repo over deprecated git filter-branch.

git filter-repo --path secrets.env --invert-paths   # purge file from all history
git filter-repo --path-rename old/:new/
git filter-repo --mailmap mailmap.txt               # rewrite authors
git filter-repo --subdirectory-filter trunk

After rewrite: force-push with --force-with-lease.

Recovery

git rebase --abort
git reflog && git reset --hard HEAD@{N}

Pitfalls

  • --autosquash needs commits made via git commit --fixup=<sha>.
  • exec make test between commits pinpoints which rewritten commit breaks the build.
  • filter-branch silently corrupts edge cases; filter-repo refuses unsafe rewrites.

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 328,083. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.