Rose Perrone Rose Perrone - 1 month ago 17
Git Question

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
.

Answer

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).

Comments