api: YAML JSON TOON Database
version: 1.0.0
format: yaml
dataset:
  id: 2799
  slug: git-recovery-workflows
  title: Git Recovery and Inspection Workflows
  description: Recoverable Git workflows for finding commits, restoring selected files, and undoing shared changes.
  summary: Recoverable Git workflows for finding commits, restoring selected files, and undoing shared changes. Each row includes a practical application and a failure to check before using it.
  use_when:
    - Recover a commit after a mistaken reset.
    - Undo a published change while preserving history.
  caveats:
    - These commands are examples; inspect your local state first.
    - Git cannot recover untracked content it never recorded.
  related:
    - git-essential-commands
    - shell-safe-file-patterns
  reviewed_at: "2026-10-12"
  sources:
    - title: Git reflog manual
      url: "https://git-scm.com/docs/git-reflog"
    - title: Git restore manual
      url: "https://git-scm.com/docs/git-restore"
    - title: Git revert manual
      url: "https://git-scm.com/docs/git-revert"
  reading:
    - recover-git-work-without-losing-local-changes
  provenance: Original editorial reference notes by YJTOON, informed by the linked primary documentation. External specifications retain their own licenses.
  entry_count: 10
  fields:
    - section: data
      field: situation
      type: string
      example: Find a recent branch position
    - section: data
      field: command
      type: string
      example: git reflog show --date=iso
    - section: data
      field: effect
      type: string
      example: List locally recorded ref movements.
    - section: data
      field: check_first
      type: string
      example: Reflogs are local and entries can expire.
  category: Unix Commands
  category_slug: unix-commands
  tags: unix-commands,git recovery workflows,reference,engineering
  view_count: 59
  created_at: 1791798640
  updated_at: 1791798640
data:
  - situation: Find a recent branch position
    command: git reflog show --date=iso
    effect: List locally recorded ref movements.
    check_first: Reflogs are local and entries can expire.
  - situation: Preserve a found commit
    command: git branch recovered <commit>
    effect: Give the commit a durable branch reference.
    check_first: Inspect the commit before switching or merging.
  - situation: Undo a shared commit
    command: git revert <commit>
    effect: Create a new commit that reverses a change.
    check_first: Review conflicts and dependent changes.
  - situation: Restore one working file
    command: git restore --source=<commit> -- path
    effect: Replace the selected working-tree path.
    check_first: Copy uncommitted work you need before replacing it.
  - situation: Unstage a file
    command: git restore --staged -- path
    effect: Remove the file from the staged change.
    check_first: It normally leaves the working file intact.
  - situation: Inspect a commit
    command: git show --stat <commit>
    effect: Read the change summary.
    check_first: Read the actual diff before relying on the summary.
  - situation: Inspect one old file
    command: "git show <commit>:path/to/file"
    effect: Print a file from a chosen commit.
    check_first: The path is relative to the repository root.
  - situation: Save local work
    command: git stash push -u -m 'before repair'
    effect: Record tracked changes and untracked files.
    check_first: Ignored files require separate preservation.
  - situation: Preview stale branches
    command: git branch --merged
    effect: List branches merged into the current commit.
    check_first: Merged does not mean the branch is safe to delete.
  - situation: Verify the destination
    command: git remote -v
    effect: Show fetch and push destinations.
    check_first: Confirm the repository before pushing a repair.
