Back to lessons

Hosting Operations

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

What changed

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

Danger

safe

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.

Undo or recovery

No undo needed because this command is read-only.

Expected output

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

demo script

Disposable terminal steps

  1. cd /lab/git-recovery-rollback && git status --short --branch
  2. cd /lab/git-recovery-rollback && git diff -- app/config.yml

simulated output

What it looks like

disposable vessel
::fixture-ready::
$ cd /lab/git-recovery-rollback && git status --short --branch
## main
 M app/config.yml
?? releases/current
::exit-code::0
$ cd /lab/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
::exit-code::0

YouTube Short

Check git status before rollback.

Before recovery commands, run a status snapshot. Dirty files are the easiest thing to overwrite by accident.

LinkedIn hook

Before rollback commands, capture the branch and dirty files.

Question: Do you snapshot git status before incident rollback work?

experiments

A/B tests to run

Metric: save_rate

A: Status first, rollback second.

B: Dirty files can derail recovery.