Back to commands

Hosting Operations

Changes system state

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

System impact: Changes system or application state. Needs inspection, scoping, and rollback notes before production use.

When not to use it: 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

Changes system state. 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

Command transcript

This sanitized transcript shows the commands and output shape without exposing host details.

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 commands shown

These are the commands shown in the sanitized transcript.

Commands shown

  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 Read-only

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 Read-only

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 State change

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 Read-only

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 Read-only

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.