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
git reset --hard HEAD~1git revert HEAD@{0}git reset --soft HEAD@{0}git reset --hard HEAD@{1}
The reflog shows
Play Git ▸
HEAD@{1} was B before the reset, so resetting to it restores the branch and files. Unreachable commits stay until garbage collection.