$ ./guess_the_languageGit
Git · hard · #31

Which command makes commit B the branch tip again?

$ git reset --hard HEAD~1
HEAD is now at 2662f61 A
$ git reflog
2662f61 HEAD@{0}: reset: moving to HEAD~1
0311bf8 HEAD@{1}: commit: B
  1. git reset --hard HEAD~1
  2. git revert HEAD@{0}
  3. git reset --soft HEAD@{0}
  4. git reset --hard HEAD@{1}
The reflog shows HEAD@{1} was B before the reset, so resetting to it restores the branch and files. Unreachable commits stay until garbage collection.
Play Git ▸