What does "fatal: bad revision" mean?


In the context:

git revert HEAD~2 myFile
fatal: bad revision '/Users/rose/gitTest/myFile'

I'm sure HEAD~2 exists.

EDIT Amber is correct. I meant to use reset instead of revert.

This question is tagged with git

~ Asked on 2013-01-27 18:41:40

The Best Answer is


If you only want to revert a single file to its state in a given commit, you actually want to use the checkout command:

git checkout HEAD~2 myFile

The revert command is used for reverting entire commits (and it doesn't revert you to that commit; it actually just reverts the changes made by that commit - if you have another commit after the one you specify, the later commit won't be reverted).

~ Answered on 2013-01-27 18:43:06


I was getting this error in IntelliJ, and none of these answers helped me. So here's how I solved it.

Somehow one of my sub-modules added a .git directory. All git functionality returned after I deleted it.

~ Answered on 2016-05-25 02:48:48

Most Viewed Questions: