git rebase fatal: Needed a single revision invalid upstream –i
I am trying to squanshing several commits together. When I used
git rebase –i HEAD~8
I got a fatal:
fatal: Needed a single revision
invalid upstream –i
Here is a part of commit logs: git log
All of the commits history of the corresponding Github repository is here: https://github.com/yikouniao/YukiLog/commits/master
Edit1:
When I used git rebase –i HEAD~2
, I got the same result.
Edit2:
I didn't know I had modified the file.gitconfig
, editor = notepad2
was add to the file. After I removed editor = notepad2
, everything is OK. Then I rebased and squanshed 8 commits successfully.
Several options:
-
You are not on a branch (
Detached head
) or maybe you are trying torebase
or the wrong branch.
Checkout the branch you want torebase
and try again. -
you don't have 8 commits in your history (you have 7 or less)
-
try:
git rebase -i --root
Here is the documentation for the --root
flag and why it will work for you.
--root
Rebase all commits reachable from <branch>, instead of limiting them with
an <upstream>.This allows you to rebase the root commit(s) on a branch.
When used with --onto, it will skip changes already contained in `<newbase>`
(instead of `<upstream>`) whereas without --onto it will operate on every
change. When used together with both --onto and --preserve-merges, all root
commits will be rewritten to have `<newbase>` as parent instead.`
The problem is the dash in your –i. It's an en-dash (U2013) instead of a hyphen (U002D). I confirmed this by copying your dash and looking it up at http://unicode.scarfboy.com. Change it to -i instead.
The clue was the error message "invalid upstream –i". Git didn't recognize your –i as a flag and was instead interpreting it as the upstream parameter.