git-workflow
Installation
SKILL.md
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).