HEAD is the last commit of the selected branch.master is a branch (main branch, conditionally), while HEAD is a place in history for the selected branch. HEAD refers to the branch you are in.git reset --soft will leave your changes in the working tree, preventing you from doing whatever you like. git reset --hard restore the working tree to the state it was in, on the commit that you reset.- No other command is required.
Firstly, to save the commit in case you want to check it later, create a branch:
git checkout -b my_bad_commit
(or alternatively git branch my_bad_commit , as pointed out by larsman.)
Then go back to master or to any branch you were in and reset:
git checkout branch_with_bad_commit git reset
HEAD ^ translates into the "parent HEAD element", which you can even drain for HEAD ^^ = 2. For more on this topic, see the git community book chapter on cancel in git
shelhamer
source share