git rebase致命:上游需要一个修订无效的-i

时间:2015-11-25 08:13:11

标签: git

我正试图将几个提交一起推出。我用的时候

git rebase –i HEAD~8

我致命了:

fatal: Needed a single revision
invalid upstream –i

以下是提交日志的一部分: git log

相应Github存储库的所有提交历史记录都在这里: https://github.com/yikouniao/YukiLog/commits/master

EDIT1:

当我使用git rebase –i HEAD~2时,我得到了相同的结果。

EDIT2:

我不知道我修改了文件.gitconfigeditor = notepad2已添加到文件中。删除editor = notepad2后,一切正常。然后我成功地重新定位了8个提交。

2 个答案:

答案 0 :(得分:58)

有几个选择:

  • 您不在分支(Detached head)或者您正在尝试rebase或错误的分支。
    检查您想要的分支rebase然后重试。

  • 您的历史记录中没有8次提交(您有7次或更少)

  • 尝试:git rebase -i --root

以下是--root标志的文档及其对您有用的原因。

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

答案 1 :(得分:4)

问题是-i中的破折号。这是一个en-dash(U2013)而不是连字符(U002D)。我通过复制短划线并在http://unicode.scarfboy.com查找来确认了这一点。将其更改为-i。

线索是错误消息“上游无效-i”。 Git没有将你的-i识别为标志,而是将其解释为上游参数。

相关问题