Back to lessons

Hosting Operations

Risk: caution

Restore One File From Last Good Release

One file is dirty or suspect, and you want to restore just that path from a known-good release tag.

Command

cd /lab/git-recovery-rollback && git restore --source=release-2026-06-25-1000 -- app/config.yml

Before you run this

Risk: caution. Do not run this on a path with uncommitted work you still need unless you have saved or reviewed the diff.

Expected output

The diff for app/config.yml changes after the targeted restore.

System impact

app/config.yml in the disposable repo is replaced with the version from release-2026-06-25-1000.

When to use it

Use when you need a targeted file recovery from a tag, commit, or branch.

When not to use it

Do not run this on a path with uncommitted work you still need unless you have saved or reviewed the diff.

Recovery / rollback

Restore the file again from HEAD or discard the disposable fixture copy.

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

$ cd /work/git-recovery-rollback && git restore --source=release-2026-06-25-1000 -- app/config.yml

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

diff --git a/app/config.yml b/app/config.yml
index 587c07b..8be1a2f 100644
--- a/app/config.yml
+++ b/app/config.yml
@@ -1,2 +1,2 @@
-version=1.2
-feature_flag=checkout-redesign
+version=1.1
+feature_flag=off
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 diff -- app/config.yml
  2. cd /lab/git-recovery-rollback && git restore --source=release-2026-06-25-1000 -- app/config.yml
  3. 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: safe

Preview the Patch a Rollback Would Apply

Show the exact file changes before moving the branch back.

cd /lab/git-recovery-rollback && git diff --stat HEAD..release-2026-06-25-1000
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

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

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.