GitHub Topics (7)Tap to view
    GitHub·Version Control·Topic 7 of 7

    GitHub Workflows & Emergency Recovery

    Review critical changes, restore previous points via Reflog, and secure push with force-with-lease.

    1. Advanced Workflows & Recovery

    1. git status

      What it doesChecks the status of the work folder and supply index before making any corrective decision

      When to use itThe obligatory first step before any historical recovery or modification

      Examplegit status

    2. git diff --cached

      What it doesDisplays the changes prepared in Staging that will go into the next commit

      When to use itto verify changes before pressing commit

      Examplegit diff --cached

    3. git reflog -10

      What it doesDisplays the history of HEAD cursor transactions locally, allowing recovery of commits not visible in the regular history

      When to use itWhen a commit is lost after an incorrect rebase or accidental reset

      Examplegit reflog -10

    4. git branch --show-current

      What it doesPrints the exact name of the currently active branch to avoid making errors on an unintended branch

      When to use itIn scripts or for verification before executing push or merge orders

      Examplegit branch --show-current

    5. git switch -c recovery/my-work

      What it doesCreates a temporary emergency branch that saves the current state before trying dangerous debug commands

      When to use itAs a precaution before complex Rebase or Revert operations

      Examplegit switch -c recovery/backup-before-rebase

    6. git branch recovery/previous-state <hash>

      What it doesCreates a new branch that points directly to the commit hash found in the reflog

      When to use itto rescue missing code that was present in an undo commit

      Examplegit branch recovery/lost-commit a1b2c3d

    7. git push --force-with-lease

      What it doesUnloads historical modifications while checking that there are no new external modifications on the remote branch

      When to use itAfter safely rewriting your branch history (such as an interactive rebase)

      Examplegit push --force-with-lease origin feature/login

    Offline · Reading cached copy