It's as simple as this:
(就这么简单:)
git reset HEAD^
git reset
without a --hard
or --soft
moves your HEAD
to point to the specified commit, without changing any files.
(无需使用--hard
或--soft
git reset
即可将HEAD
移至指定的提交,而无需更改任何文件。)
HEAD^
refers to the (first) parent commit of your current commit, which in your case is the commit before the temporary one. (HEAD^
是指您当前提交的(第一个)父提交,在您的情况下,它是临时提交之前的提交。)
Note that another option is to carry on as normal, and then at the next commit point instead run:
(请注意,另一个选项是照常进行,然后在下一个提交点运行:)
git commit --amend [-m … etc]
which will instead edit the most recent commit, having the same effect as above.
(而是编辑最新的提交,效果与上述相同。)
Note that this (as with nearly every git answer) can cause problems if you've already pushed the bad commit to a place where someone else may have pulled it from.
(请注意,如果您已经将错误的提交推送到其他人可能已将其撤出的地方,则此问题(几乎与每个git答案一样)可能会导致问题。)
Try to avoid that (尽量避免这种情况)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…