Ivo's label fix vanished from the release clone REL-262

Open2 versionsGit · Medium · Recover · about 25 min ·Linux

Lab machine

A private Linux machine with the problem already set up. Sessions last up to 60 minutes.
Dmitri Vos opened REL-262 at 16:50SEV-4

Dmitri tidied his clone of Waybill before going home, and Ivo's South Sorting label fix went with it. South Sorting opens tomorrow at 06:00, tonight's build needs the fix, and Ivo is on a plane until Thursday.

Nothing was pushed, so the only copy of Ivo's commit is in Dmitri's repository. A reset or a deleted branch removes a name, not the commit: Git keeps a log of every place HEAD has been.

"Please don't make me ask Ivo to redo it. Also, my runbook edit isn't committed yet, don't lose it." (Dmitri)

The hard part is the recovery. Since the loss, main has moved on by one commit, and there is uncommitted work in the tree.

Your task

Put Ivo's South Sorting fix back on main as his own commit. Keep Dmitri's newer changelog commit, leave out anything else that was dropped, and do not touch the runbook edit.

On the machine

  • notes/dmitri-terminal.txt: what Dmitri typed
  • git reflog: everywhere HEAD has been, including commits no branch points to
  • git log --oneline main, git status
  • git show <commit>: what a lost commit contains

Timeline

10:12Ivo commits the South Sorting (depot-9) label template and printer, then leaves for the airport.
15:40Dmitri tidies his clone before going home.
16:20He commits the 2.5.3 changelog and starts a runbook edit.
16:50"Where did Ivo's label fix go?"

Done when

  1. main has Ivo's South Sorting fix, recovered as his commit, not retyped.
  2. Dmitri's later changelog commit stays on main, and nothing else that was dropped comes back.
  3. The unfinished runbook edit is still in the working tree, uncommitted.

Hints

Hint 1

Dmitri's terminal says what he ran, not what it did. `git reflog` shows every place HEAD has been.

Hint 2

Find the entry where Ivo's commit was made, and `git show` it before you use it.

Hint 3

main has moved on since. Moving main back would lose Dmitri's changelog commit and, with --hard, the runbook edit.

Hint 4

`git cherry-pick <commit>` copies one commit onto the current branch and keeps its author. It works with an uncommitted change in an unrelated file.

Show the solution

Run `git reflog` and find the commit "labels: South Sorting (depot-9) template and printer". Check it with `git show <hash>`. On main, run `git cherry-pick <hash>`. The runbook edit is in another file, so it stays as it was. Confirm with `git log --format='%h %an %s' -3` and `git status`.