How can I fix a reverted git commit?
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
When you revert a Git commit with git revert, Git creates a new commit that undoes the changes. If you later want those changes back, you cannot simply re-merge or cherry-pick the original commit — Git sees the revert as intentional and skips the already-applied changes. The fix is to "revert the revert" — create a new commit that undoes the revert commit, effectively re-applying the original changes. Use git revert <revert-commit-hash> to undo the revert, or git cherry-pick the original commit if the history is complex.
Understanding Git Revert
git revert does not delete or modify history. It creates a new commit with the inverse diff. The original commit (abc1234) still exists in history, but its changes are undone by the revert commit (999aaaa).
Fix 1: Revert the Revert
This is the cleanest approach for shared branches. It preserves full history and creates an explicit record of the revert-then-re-apply decision.
Fix 2: Cherry-Pick the Original Commit
Cherry-picking copies the original commit's changes into a new commit. This works when you want to selectively re-apply changes, but on the same branch where the revert exists, Git may detect that the changes were already applied and reverted.
Fix 3: Reverted Merge Commit
Reverting a merge commit is especially tricky. If you later try to re-merge the feature branch, Git thinks all its changes are already in the target branch (because the merge commit exists in history). You must revert the revert first.
Fix 4: Interactive Rebase (Unpushed Only)
Interactive rebase rewrites history, so only use this for commits that have not been pushed to a shared remote. After pushing, other developers have the revert in their history.
Fix 5: Re-Apply with Modifications
--no-commit stages the revert of the revert without creating a commit, giving you a chance to modify the changes before committing. This is useful when the original code needed fixes.
Identifying the Revert Commit
Common Pitfalls
- Trying to re-merge a reverted merge branch: After reverting a merge, Git considers all the merged changes as already applied. Re-merging the same branch is a no-op. You must first revert the revert commit, then merge new changes from the feature branch.
- Using
git reseton pushed commits:git reset --hardremoves commits from local history but breaks the shared repository if the commits were already pushed. Other developers will have divergent histories. Usegit revertfor pushed commits. - Forgetting
--no-commitwhen modifications are needed:git revert <hash>creates a commit immediately. If you need to modify the re-applied changes (fix the bug that caused the revert), use--no-committo stage changes first. - Cherry-picking a commit that was already reverted on the same branch: Cherry-picking the original commit onto a branch where its revert exists can cause conflicts or be silently ignored because Git sees the net effect as zero. Revert the revert instead.
- Not communicating the revert-revert to the team: Reverting a revert creates confusing history (
Revert "Revert "Feature X""). Write a clear commit message explaining why the changes are being re-applied and what was fixed, so other developers understand the intent.
Summary
- To re-apply a reverted commit, "revert the revert" with
git revert <revert-hash> - For reverted merge commits, revert the revert before attempting to re-merge the feature branch
- Use
--no-committo stage the re-applied changes and make modifications before committing - Only use
git rebase -ito drop revert commits that have NOT been pushed to shared remotes - Use
git log --grep="Revert"to find revert commits in history - Write clear commit messages explaining the revert-revert to avoid confusing team members

