You Reverted the Merge. Why Didn't Git Bring the Changes Back?
A merge revert changes the files but leaves Git’s ancestry intact. Check which commits are already reachable and choose a recovery that restores only what you need.
You reverted a faulty merge, fixed the feature on its original branch, and merged again. The follow-up arrives. The original feature is still missing. Git may even say “Already up to date” if there are no new commits to merge. That sounds like a verdict on the files. It's a verdict on the history.
Reverting a Git merge reverses its changes relative to a chosen parent, but leaves the merge and its parents in the commit graph. The original feature commits are still ancestors of the target branch. Merging the same branch again doesn't replay their changes. If the feature was fixed by adding commits on top of that same history, consider reverting the revert on a recovery branch, then merging the fix there. If the feature was rebuilt as new commits, inspect that branch instead of blindly restoring the old patch.
This is an AI-prepared, documentation-based explainer, not a personally reproduced production incident. The opening scenario is illustrative. The behavior below was checked in a disposable local Git repository; the diagnostic commands are illustrative and use placeholder refs. See Debugly's editorial policy.
The file is gone. The commit isn't.
Suppose a feature branch adds feature.txt. A merge commit brings it into main, and a revert removes it again. In the working tree the feature is gone. In the graph the merge still connects the two branches, and the commit that added the file is still reachable from main. Git has remembered the introduction and the removal. It hasn't decided to introduce it a second time just to be polite.
The git revert manual describes -m as choosing the merge parent against which to reverse the merge's change. In the common case of a merge made while on main, parent 1 is the previous main tip. Check the parents on the actual commit before using a number. That choice determines the patch being undone; it doesn't rewrite the parent links.
In a disposable lab using Git 2.51.1, merging the unchanged feature branch after the revert returned Already up to date. After adding a new fix.txt commit on the same feature branch and merging again, fix.txt was present and feature.txt was absent. That second merge had something new to integrate, but the original addition was already part of its shared history.
Prove it with two separate questions
First ask what the original merge changed. Then ask whether the original feature tip is already in the target's history. These read-only checks answer those questions without trying another merge:
# Illustrative: replace these values with the actual commit IDs.
merge=MERGE_COMMIT
original=ORIGINAL_FEATURE_TIP
target=main
git show -s --format='%h parents: %p' "$merge"
git diff "${merge}^1" "$merge"
git merge-base --is-ancestor "$original" "$target"
The diff uses parent 1 here because that's the assumed mainline in the example; choose the parent you actually meant to keep. The merge-base manual documents exit status 0 when the first commit is an ancestor, 1 when it isn't, and other nonzero statuses for errors. Use the original feature tip that was merged, not the current feature tip after additional commits.
If the original tip is an ancestor but its file is absent, look for the later tree change. A revert is a common explanation; it isn't the only one. Check the revert's diff and any intervening commits that touched the file. This is the same discipline as using git bisect to narrow a regression: ask a question Git can actually answer, rather than interpreting a reassuring status line as proof of the behavior you wanted.
Choose the fix based on what happened to the feature branch
| What the branch contains now | What to try on a recovery branch |
|---|---|
| The same original commits plus fixes on top | Reverse the revert to restore the original merge's change, then merge the follow-up. Test the combined result before integrating it. |
| A rebuilt feature made from new commits | Inspect and test the merge of the rebuilt branch. Reversing the old revert as well can restore code you deliberately replaced. |
| Only some of the original feature should return | Make a new patch for that subset. Reversing the entire revert is too broad. |
The Git project's faulty merge HOWTO explains why the first two cases need different treatment. Restoring the revert's inverse can conflict with subsequent changes. It can also temporarily reintroduce the original bug in the recovery branch, which is why the combined, reviewed patch is the thing to integrate.
# Illustrative: start from the intended target tip in a clean worktree.
git switch -c recover-feature main
git revert REVERT_COMMIT
git merge feature
# Review the resulting diff and run the feature's regression checks.
Here REVERT_COMMIT is the ordinary commit that undid the merge, not the original merge commit. It normally has one parent, so the command doesn't use -m. In the lab, reversing that commit before merging the follow-up restored both files. The real repository may need conflict resolution or a narrower patch. Don't reset shared history to make the graph look prettier.
Make the next rollback easier to undo
When reverting a merge, record the original merge ID, the mainline parent and whether the feature should be repaired on its existing branch or rebuilt. Add a regression check for the original behavior as well as the fix. “Merge succeeded” says the histories were integrated. It's the diff and the test that tell you whether the feature came back.