为什么当我使用提交哈希时 git revert 告诉我“错误修订”?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21608432/
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
Why is git revert telling me "bad revision" when I use a commit hash?
提问by Ellen Spertus
I am trying to revert to an earlier git commit but get the error "bad revision". Why?
我正在尝试恢复到较早的 git 提交,但收到错误“错误修订”。为什么?
Here is a transcript (with author names removed):
这是一个成绩单(删除了作者姓名):
Ellen@ELLEN-PC /c/Users/Susan Mills/git/hello-github (master)
$ git status
# On branch master
nothing to commit, working directory clean
Ellen@ELLEN-PC /c/Users/Susan Mills/git/hello-github (master)
$ git log | head
commit e3eb30cc7ca6d4cd10de755b63821cad75da1e83
Date: Wed Feb 5 17:54:32 2014 -0800
I changed my greeting.
commit 063ac580e28bab524286dac7b0a8f88d9e7d365f
Date: Mon Feb 3 07:53:19 2014 -0800
Ellen@ELLEN-PC /c/Users/Susan Mills/git/hello-github (master)
$ git revert 9e7d365f
fatal: bad revision '9e7d365f'
Why am I getting "bad revision", and what should I do? I am using git bash
on Windows 7 with my origin on github.
为什么我会收到“糟糕的修订”,我该怎么办?我git bash
在 Windows 7 上使用我的来源在 github。
回答by Wolf
When you use the short version of a SHA1, you use the prefix, not the suffix. So you actually want to say:
当您使用 SHA1 的简短版本时,您使用的是前缀,而不是后缀。所以你实际上想说:
git revert 063ac580
回答by Michael Durrant
Use the beginning of the hash as identification, as in:
使用哈希的开头作为标识,如下所示:
git revert 063ac580e2
回答by Schleis
You are trying to revert that doesn't exist. The SHA that starts with 9e7d365f is not in your repository.
您正在尝试还原不存在的内容。以 9e7d365f 开头的 SHA 不在您的存储库中。