~/guides/GITHUB.md

Guides / Claude Code

Claude Code broke your project? Rescue it with three git commands: commit, restore, push

/rewind can't track files changed by shell commands; real saves need Git. Commit when it works, restore when it breaks, push to GitHub as a backup.

Claude Code broke your project halfway through? You don't have to start over. This is the full version of my GITHUB reel: three git commands, one to save, one to roll back, one to back up to GitHub. Every output shown was really run on a small project on 2026-11-17, and the official docs were checked the same day.

01What you get: one command back to the version that worked

Reel frame: terminal git status --short listing four broken files in red
Reel frame: Claude Code broke four files.

After this you'll be able to:

  1. Save a snapshot while the project works (commit).
  2. Roll everything back to the last snapshot in one command (restore).
  3. Back the snapshots up to GitHub so they survive a dead laptop (push).
  4. Know why Claude Code's /rewind is no replacement for Git.
Reel frame: docs paragraph Bash command changes not tracked, /rewind circled
Reel frame: /rewind isn't a save; the docs say use Git.

02Why /rewind alone isn't enough

Claude Code has /rewind (or press Esc twice), which undoes files Claude changed with its edit tools. But the official checkpointing page is clear: a file changed only by Bash commands isn't tracked, and to revert it you use version control such as Git. The docs also say checkpoints are not a replacement for version control.

Claude Code checkpointing docs: the Bash command changes not tracked section
The official docs (captured 2026-11-17).

03Step 0: install Git and run git init in the project (once)

  1. Download and install Git from git-scm.com/downloads.
  2. In a terminal, go into your project folder.
  3. Run git init; the folder is now tracked by Git.
Once only
git init

04Step 1: save when it works (git commit)

Every time the project works, save a snapshot. Write any message you'll understand:

Save
git add .
git commit -m "working version"
Terminal: git add . and git commit -m with the root-commit 0e65fc2 line and 4 files changed
Real output: the first snapshot, 0e65fc2.

05Step 2: broke it again? git restore goes back to the last save

Terminal: git status --short showing README.md, index.html, src/app.js and src/style.css modified
Real output: four files broken.
Back to the last save
git restore .
Terminal: after git restore . the status reads nothing to commit, working tree clean
Real output: working tree clean, back to the working version.

06Step 3: back up to GitHub with git push

  1. Create a repo at github.com/new (Private is fine).
  2. Follow the new repo page and paste its git remote add origin … lines into your terminal, once.
  3. After every commit from then on, run git push.
After every save
git push
Reel frame: a cracked laptop next to a GitHub card showing 0e65fc2 still there
Reel frame: even if the laptop dies, the save is still on GitHub.

07Good to know

  1. git restore . discards uncommitted changes for good; be sure you don't want them first.
  2. Don't commit files with passwords or API keys (like .env); add them to .gitignore first.
  3. /rewind is still handy as a quick undo inside a Claude session; leave real saves to Git.
  4. Commands and docs as of 2026-11-17.

Sources

Related guides