git revert is not reverting anything

Viewed 2218

I am running the command

git revert bf0db5abaca25748a85aaf3cffc4154b3a6e045a

, which is an earlier commit with significant changes, but it does absolutely nothing. The output is

Your branch is ahead of 'origin/master' by 2 commits.
  (use "git push" to publish your local commits)

Untracked files:

And then it lists a bunch of files, which indeed should not be tracked. The files that are tracked, however, are not reverted.

I am nervous to use git reset as I have already pushed some changes that I want to get rid of. What am I doing wrong with revert? If it is relevant, I have reverted to the same commit before, and it worked fine then.

Thank you.

1 Answers

That's what happens when reverting a commit would do nothing. I can reproduce it by doing a revert and then trying to "revert" the commit we just reverted:

$ git log --oneline
e5ce573 (HEAD -> master) Revert "two"
876711f two
0849cb0 one
$ git revert 876711f
On branch master
nothing to commit, working tree clean

Nothing happens, because two is what we did just revert; reverting it again results in no change.

So I'm guessing that you're in a similar situation. Try doing a diff between the commit before the one you are reverting and where you are now; if it comes up empty, that's the reason.

Related