It's as simple as this:
git reset HEAD^
Note: some shells treat ^
as a special character (for example some Windows shells or ZSH with globbing enabled), so you may have to quote "HEAD^"
in those cases.
git reset
without a --hard
or --soft
moves your HEAD
to point to the specified commit, without changing any files. HEAD^
refers to the (first) parent commit of your current commit, which in your case is the commit before the temporary one.
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. Try to avoid that
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…