0

I have a query regarding reverting an earlier commit which has been overridden by a future commit.

Consider a simple scenario - I have a commit history in which I have say 10 commits. My 3rd commit is for a change to file dummy.html on line 3,4,5 and my 5th commit is also for that dummy.html file on the same lines 3,4,5. It means 3rd commit's change is overridden by 5th commit change.

will there be any conflict in reverting 3rd commit?

Help will be appreciated.

naruto
  • 1
  • I think you will get a conflict, since when you are applying the inverse of your 3rd commit, it will try to merge it to the tip of your branch, and see that in those lines, something is not the same, thus causing a conflict. – mnestorov Mar 03 '20 at 11:11

1 Answers1

0

Most probably yes. Since you are reverting an old commit onto the tip of your current branch, git will see that a subsequent commit has done changes to your dummy.html file. Git will try to merge your revert commit to the tip and tell you that there is a conflict happening.

But that's okay, since you can always --abort the revert.

Check this answer for more details or this article on revert.

mnestorov
  • 4,116
  • 2
  • 14
  • 24