Unable to comment on others answers, I'll provide a bit of extra information. If you want to revert the last commit, you can use git revert head. head refers to the most recent commit in your branch. The reason you use head~1 when using reset is that you are telling Git to "remove all changes in the commits after" (reset --hard) "the commit one before head" (head~1). reset is to a commit, revert is on a commit. As AmpT pointed out, you can also use the commit SHA to identify it, rather than counting how far away from head it is. The SHA can be found in the logs (git log) and a variety of other ways. You can also always use any other pointers in Git. e.g. a tag or branch. And can also use all of these fun other ways to reference commits (责任编辑:) |