develop and main are usually protected — no reset, no force-push — so undoing means new commits on top. git revert needs a commit range and a -m parent decision per merge commit: many chances to pick wrong.
| |
The fallback is a second clone: target branch checked out elsewhere, everything but .git deleted, the good branch’s contents copied in, commit — works, miserable.
The one-liner
git restore copies files out of any revision into the working tree without touching the index, unlike git checkout or git reset, which move it — so the desired tree pulls in on the protected branch:
| |
A file or glob narrows it:
| |
restore only writes the working tree, so the revert still needs its commit:
| |
No merge parents, no commits to enumerate, and the history stays append-only — the reason for protection.