>_ IzzyLab

Hands-on task

This task is step 18 of the course “Investigating a server”

Investigation notes in detached HEAD

medium~5 min

A teammate kept the incident timeline in the repository /root/ir-notes: they checked out an old commit to compare something and committed timeline.md right there. The repository was left in a detached HEAD state — the timeline commit belongs to no branch, and the very first git switch main will lose it. Save it: create a branch incident-42 whose tip is that commit with timeline.md.

What you'll practise:
  • detached HEAD
  • git branch
  • git switch
  • git reflog
  • commit references

Topic breakdown

A git branch is just a movable pointer to a commit, and HEAD usually points to a branch. If you checkout a specific commit, HEAD starts pointing directly at it — that's detached HEAD. New commits made in this state aren't held by anything: after switching to a branch they become unreachable, and the garbage collector eventually removes them. The fix is to create a branch on the current commit (git branch or git switch -c) while you're still on it; if you missed the moment, the commit hash is still visible in git reflog, and you can create the branch from it.

What's checked

  1. branch incident-42 exists
  2. timeline saved in the branch

What it looks like