Back to lessons

Hosting Operations

Risk: safe

Snapshot Git Status Before Recovery

An incident starts with an unknown working tree, and you need to see whether local edits could be overwritten by recovery work.

Command

cd /lab/git-recovery-rollback && git status --short --branch

Before you run this

Risk: safe. Do not treat status alone as a release audit; inspect the commit history and deployment pointer too.

Expected output

A short branch line for main and a modified app/config.yml entry.

System impact

Nothing changes. Git prints the current branch and working-tree state.

Recovery / rollback: no state is changed.

When to use it

Use before reset, restore, checkout, revert, or rollback work so local edits are visible.

When not to use it

Do not treat status alone as a release audit; inspect the commit history and deployment pointer too.

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 status --short --branch

## main
 M app/config.yml
?? releases/current

$ cd /work/git-recovery-rollback && git diff -- app/config.yml

diff --git a/app/config.yml b/app/config.yml
index 587c07b..eb4e72d 100644
--- a/app/config.yml
+++ b/app/config.yml
@@ -1,2 +1,3 @@
 version=1.2
 feature_flag=checkout-redesign
+debug_logging=true
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 status --short --branch
  2. cd /lab/git-recovery-rollback && git diff -- app/config.yml

next steps

Related commands

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: caution

Branch a Recovered Commit

Put a name on the reflog commit before it slips away.

cd /lab/git-recovery-rollback && git branch recovered-incident-note HEAD@{1}
Hosting Operations Risk: caution

Restore One File From Last Good Release

Recover a config file without rolling back the whole branch.

cd /lab/git-recovery-rollback && git restore --source=release-2026-06-25-1000 -- app/config.yml
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

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
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
  • risk:read-only

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.