← Git: team decisions and recovery
04 / 5 · 18 MIN

Reverse changes and preserve work

Choose recovery appropriate to what was saved and shared.

Concept and mechanism

Revert creates a new change counteracting the effects of a chosen commit. It is useful when shared history needs to remain traceable. It does not erase the earlier occurrence or guarantee the entire environment returns to its old state. Restore operates on paths in the index or working tree according to options. Reset can move references and, with certain options, replace index and files. Start by asking: what do I want to change, what has been saved, and who depends on this history?

Guided application

In a release scenario, identify the artifact’s commit and later changes that must remain. Prepare reversal on a branch, analyze conflicts, and verify the application against current data state. If a credential was exposed, removing it from the current commit neither revokes it nor removes every historical copy. Contain exposure, rotate the secret through the applicable process, and coordinate any history cleanup. Do not assume a Git command performs these external actions.

IN PRACTICE

A published fix broke the parser, but a later fix is still needed. A targeted revert can preserve history and later work, subject to compatibility and conflicts.

Common pitfalls

Using reset --hard as the first response; confusing code reversal with data reversal or secret revocation.

Related topics: Diagnosis and release traceability · Working tree, index, and commit

Take this idea with you

Recover the required state without assuming Git controls every release effect.

Create account

Reference: Git: reversing existing commits · Git 2.56; workflow concepts compatible with modern Git 2.x