{"success":true,"name":"never-rewrite-shared-git-history-force-push-only-what-is-you","description":"About to rebase, amend, or force-push a Git branch others may have pulled","category":"ai-brimind","path":"ai-brimind/never-rewrite-shared-git-history-force-push-only-what-is-you/SKILL.md","file":"SKILL.md","content":"---\nname: never-rewrite-shared-git-history-force-push-only-what-is-you\ndescription: \"About to rebase, amend, or force-push a Git branch others may have pulled\"\n---\n\n# Never Rewrite Shared Git History: Force-Push Only What Is Yours Alone\n\n## When to use\nWorking with Git on a shared repo, and you're about to rebase, amend, squash, or force-push a branch that anyone else might have fetched.\n\n## Example request\nForce-push to main after a rebase → every teammate's local history diverges and their next push becomes a fight; rewritten shared history multiplies pain by team size. — Amending a commit that was already pushed and pulled by a reviewer → their branch now points at a commit that no longer exists; amend is for unpushed work. — Cleanup rebase on your own unshared feature branch → perfectly fine; the rule is about who else holds the old commits, not about rebase itself. — Force-push needed on your own branch after review squash → force-with-lease refuses if someone pushed meanwhile; it's the built-in seatbelt over raw force.\n\n## Instructions\nAct as an archivist who knows a published record has copies: you can rewrite your private drafts freely, but rewriting what others already hold creates two versions of the truth. Before any history-changing Git action (rebase, amend, squash, reset, force-push): 1) Answer the one deciding question — could anyone else have fetched these commits? Your unpushed work: rewrite freely, cleanup is healthy. Your own pushed feature branch: rewriting is acceptable if you're truly its only consumer, and force-with-lease is the mandatory form — it aborts if someone pushed in between, raw force overwrites them blind. Shared branches (main, develop, anything teammates build on): never rewrite, full stop. 2) When something on a shared branch must be undone, use the forward-moving mechanism: revert creates a NEW commit that undoes the old one, keeping history append-only so no one's clone breaks — that is the designed tool for public mistakes. 3) If a secret was pushed, history rewriting is not the fix you think: the secret is already exposed — rotate it FIRST, then decide about history scrubbing as a separate coordinated step. 4) Protect the rule structurally: enable branch protection so force-pushing main is impossible rather than merely forbidden — make the correct way the only way. If you're unsure whether a branch is shared, ask or check who has based work on it before rewriting. Only rewrite once you've confirmed you are the sole holder of the old commits, and explain why the chosen mechanism (rebase, revert, or force-with-lease) fits who else holds the history — not just what makes your log look clean.\n\n## Metadata\n- role: developer\n- level: tactical\n- places: vibeCoding\n- origin: ai.brimind.pro skill #979\n","linked_files":[],"origin":"ai.brimind.pro","owner_id":null,"source":"router"}