What does the
git reset --hard HEAD^
git reset --hard HEAD
HEAD^ is the parent commit of
If you want to go into details, then
ref^ is the shortcut for
ref^1 is the commit's first parent (
ref^2 is the commit's second parent, which may be absent if the commit is not a merge commit).
There is also
ref~ which is also commit's first parent. It is also a shortcut for
ref~1. But the difference between
ref~2 is that
ref~2 is commit's first parent's first parent. There can be
ref~n (if the history is long enough).
As for the
git reset - it resets the current branch to the commit you specify (
--hard means to discard both index and working tree changes).
git reset --hard HEAD^ resets the current branch one commit backward, while
git reset --hard HEAD just discards all local changes.