【发布时间】:2018-05-01 05:09:52
【问题描述】:
我知道这个问题已经被问了数千次,我尝试了所有解决方案,但都没有奏效。
我提交了本地 2-3 个文件,现在我想撤消提交。我该怎么做:这也是第一次提交。
git reset HEAD^
fatal: ambiguous argument 'HEAD^': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
更新:
git reset --soft HEAD~1
fatal: ambiguous argument 'HEAD~1': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
更新 2:
git reset --hard HEAD~1
fatal: ambiguous argument 'HEAD~1': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
【问题讨论】:
-
这是你第一次提交吗?所以重置到 HEAD^ 是不可能的,因为没有提交去。
-
关闭,但您需要“~”而不是“^”:stackoverflow.com/questions/927358/…
-
@SketchyCoder:不太正确。两者都是有效的,但在不同的上下文中具有不同的含义。所以我最初的问题仍未得到解答:是否只有一次提交,是第一次提交吗?
-
@johndoe,在我提供的链接中你有答案。删除
.git文件夹或使用update-ref。
标签: git