Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git: Needed a single revision error

Tags:

git

People also ask

How do I cancel rebase?

You can run git rebase --abort to completely undo the rebase. Git will return you to your branch's state as it was before git rebase was called. You can run git rebase --skip to completely skip the commit.

What is git rebase -- root?

Git has a built in way to rebase all the way back to the beginning of time. There is no need to scroll through the log to find the first hash, or find the total number of commits. Just use --root .


In your case, there is no HEAD~2, since you only have 2 commits, hence the "Needed a single revision" error message.
Try:

 git rebase -i --root

see more about --root at "Change first commit of project with Git?"


This doesn't apply to your case, but may help others. If on Linux, make sure HEAD is capitalized. If you use lowercase head like the first example below (because you are used to working on Windows or Mac and those allow lowercase head), you will get the fatal: Needed a single revision error!

Or you can use @ as an alias for HEAD, then you won't need to worry to forgetting to capitalize it.

# wrong on linux
git rebase --interactive head~2

# correct on linux
git rebase --interactive HEAD~2

# correct on all
git rebase --interactive @~2