如何取消提交我在Git中的最后一次提交 [英] How to uncommit my last commit in Git
问题描述
是否它是
git reset --hard HEAD
或
git reset --hard HEAD ^
?
如果您不完全确定uncommit的含义并且不知道是否要使用 git reset
,请参阅恢复到之前的Git提交 。
如果您想更好地理解 如果您知道要使用 如果您想撤销提交的动作以及您上演的所有内容,请将作品树(您的文件完好无损): 如果您真的想完全撤消它, 抛弃所有未提交的更改,将所有内容重置为前一个提交 (如原问题所述): 原始问题还要求 以下是 ^ )的所有方法的noreferrer> git-rev-parse文档只是很多中的基本代码)。 How can I uncommit my last commit in git? Is it or ? If you aren't totally sure what you mean by "uncommit" and don't know if you want to use If you're trying to understand If you know you want to use If you want to undo the act of committing and everything you'd staged, but leave the work tree (your files intact): And if you actually want to completely undo it, throwing away all uncommitted changes, resetting everything to the previous commit (as the original question asked):
The original question also asked it's Here's the portion of the git-rev-parse documentation describing all of the ways to specify commits ( 这篇关于如何取消提交我在Git中的最后一次提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! git reset
,请参阅。
git reset
仍然取决于你的意思是不承诺。如果你想要做的只是撤消提交行为,而保留其他所有内容,请使用:
git reset --soft HEAD ^
git reset HEAD ^
git reset --hard HEAD ^
HEAD ^
不是 HEAD
。 HEAD
指的是当前提交 - 通常是当前签出分支的提示。 ^
是一个可以附加到任何提交说明符的符号,意思是之前的提交。因此, HEAD ^
是当前提交之前的提交,就像 master ^
提交之前的提交一样。 master分支。
git reset --hard HEAD
git reset --hard HEAD^
git reset
, please see "Revert to a previous Git commit".git reset
better, please see "Can you explain what "git reset" does in plain English?".
git reset
, it still depends what you mean by "uncommit". If all you want to do is undo the act of committing, leaving everything else intact, use:git reset --soft HEAD^
git reset HEAD^
git reset --hard HEAD^
HEAD^
not HEAD
. HEAD
refers to the current commit - generally, the tip of the currently checked-out branch. The ^
is a notation which can be attached to any commit specifier, and means "the commit before". So, HEAD^
is the commit before the current one, just as master^
is the commit before the tip of the master branch.^
is just a basic one among many).