Back to lessons

Hosting Operations

Risk: caution

Branch a Recovered Commit

You found a useful discarded commit in reflog and need to preserve it with a branch name.

Command

cd /lab/git-recovery-rollback && git branch recovered-incident-note HEAD@{1}

Before you run this

Risk: caution. Do not create branches from reflog entries you have not inspected if the repository contains sensitive or unrelated work.

Expected output

The new branch points at the recovered incident note commit.

System impact

A local branch named recovered-incident-note is created inside the disposable demo repository.

When to use it

Use when a reflog entry contains work you may need to inspect, cherry-pick, or restore later.

When not to use it

Do not create branches from reflog entries you have not inspected if the repository contains sensitive or unrelated work.

Recovery / rollback

Delete the local branch with git branch -D recovered-incident-note inside the demo repo.

Watch this command run

Example output from a temporary Linux lab

This example uses disposable sample files and sanitized output so you can inspect the shape of the result before touching a real system.

demo@lab:~$

$ cd /work/git-recovery-rollback && git show -s --format='%h %s' HEAD@{1}

7e5872b Capture incident rollback note

$ cd /work/git-recovery-rollback && git branch recovered-incident-note HEAD@{1}

$ cd /work/git-recovery-rollback && git log --oneline recovered-incident-note -1

7e5872b Capture incident rollback note
View reproducible demo details

This page shows the sanitized shell transcript and the setup steps needed to reproduce the example.

Lab setup steps

  1. cd /lab/git-recovery-rollback && git show -s --format='%h %s' HEAD@{1}
  2. cd /lab/git-recovery-rollback && git branch recovered-incident-note HEAD@{1}
  3. cd /lab/git-recovery-rollback && git log --oneline recovered-incident-note -1

next steps

Related commands

Hosting Operations Risk: safe

Snapshot Git Status Before Recovery

Before rollback commands, capture the branch and dirty files.

cd /lab/git-recovery-rollback && git status --short --branch
Hosting Operations Risk: safe

Find a Discarded Commit in Reflog

A reset does not mean the commit vanished.

cd /lab/git-recovery-rollback && git reflog --date=iso --format='%h %gd %gs' -6
Hosting Operations Risk: caution

Revert the Suspect Release Commit

Undo a bad release with a new commit instead of rewriting history.

cd /lab/git-recovery-rollback && git restore -- app/config.yml && git revert --no-edit release-2026-06-25-1030
Hosting Operations Risk: safe

Show Files Changed Since Last Good Release

Compare the suspect release against the last known-good tag.

cd /lab/git-recovery-rollback && git diff --name-status release-2026-06-25-1000..HEAD
Hosting Operations Risk: safe

Map Recent Release Commits

A rollback is easier when the last few release tags are visible.

cd /lab/git-recovery-rollback && git log --oneline --decorate --graph --all -8
Study mapping

Use this as independent command practice: read the notes, predict the output, then compare it with the example before using a real shell.

  • lfcs:operations-deployment
  • lfcs:services-logs
  • linuxplus:provisional
  • linuxplus:troubleshooting
  • risk:production-state-change

Useful for

  • LPIC-1 style command-line practice
  • LFCS style performance tasks
  • Linux+ style troubleshooting review

Independent study support only. No affiliation, endorsement, exam dumps, or real exam questions.