Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does "fatal: bad revision" mean?

Tags:

git

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.

like image 651
Rose Perrone Avatar asked Jan 27 '13 18:01

Rose Perrone


People also ask

What is fatal bad revision?

The error message "bad revision" indicates that the local repository in your build doesn't contain one of the commits you're referencing. This happens because Pipelines does a shallow clone by default, containing just the most recent 50 commits on the current branch.

How do I undo last commit?

The revert command You can find the name of the commit you want to revert using git log . The first commit that's described there is the last commit created. Then you can copy from there the alphanumerical name and use that in the revert command.


2 Answers

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

like image 199
Amber Avatar answered Oct 15 '22 00:10

Amber


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.

like image 21
BenR Avatar answered Oct 15 '22 00:10

BenR