Git:需要一个修订错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/26174757/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Git: Needed a single revision error
提问by Olkunmustafa
I initialized a new git in my project and I have only two commits so far. My log is like below
我在我的项目中初始化了一个新的 git,到目前为止我只有两次提交。我的日志如下
git log
commit e515e5b8dcbd8f1ea4a7a7d4a1efb82a1a0aee7a
Author: Olkun Mustafa <[email protected]>
Date: Fri Oct 3 10:04:20 2014 +0300
Temp commit
commit 71781bf0a7807351a56d5155dac94169ea700527
Author: Olkun Mustafa <[email protected]>
Date: Fri Oct 3 10:01:42 2014 +0300
First Commit
When I try to rebase this commits I get error like below
当我尝试重新设置此提交时,我收到如下错误
git rebase --interactive HEAD~2
fatal: Needed a single revision
invalid upstream HEAD~2
I quite research at google but I haven't found solution till now.
我在谷歌相当研究,但直到现在我还没有找到解决方案。
回答by VonC
In your case, there is no HEAD~2
, since you only have 2 commits, hence the "Needed a single revision
" error message.
Try:
在您的情况下,没有HEAD~2
,因为您只有 2 次提交,因此出现“ Needed a single revision
”错误消息。
尝试:
git rebase -i --root
see more at "Change first commit of project with Git?"
请参阅“使用 Git 更改项目的首次提交?”
回答by wisbucky
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!
这不适用于您的情况,但可能对其他人有所帮助。如果在 Linux 上,请确保HEAD
大写。如果你head
像下面的第一个例子一样使用小写(因为你习惯于在 Windows 或 Mac 上工作并且那些允许小写head
),你会得到fatal: Needed a single revision
错误!
Or you can use @
as an alias for HEAD
, then you won't need to worry to forgetting to capitalize it.
或者您可以将其@
用作 的别名HEAD
,那么您就不必担心忘记将其大写。
# wrong on linux
git rebase --interactive head~2
# correct on linux
git rebase --interactive HEAD~2
# correct on all
git rebase --interactive @~2