FunctionRacerProblemsRace

Get Them Back

HardGita shell script

Someone ran git reset --hard on main by mistake, and its last commits no longer show in the log. Nothing has been done since. Put main back where it was just before that reset.

Example 1

starts as
* cd7750c (HEAD -> main) two
* 0cbd544 one
nothing to commit
git reflog says:
  cd7750c HEAD@{0}: reset: moving to HEAD~2
  bb39c58 HEAD@{1}: commit: four
  4478d7a HEAD@{2}: commit: three
  cd7750c HEAD@{3}: commit: two
  0cbd544 HEAD@{4}: commit (initial): one
ends as
on branch: main
commits, newest first:
  four
  three
  two
  one
staged: nothing
changed, not staged: nothing
untracked: nothing

Constraints

Race itor take your time

Write it in your browser, against the clock. The model script, with a note on each command it uses, comes after.

More Git problems