Git, undo and sessions: rewind and resume

Make mistakes safely in Claude Code. Use git commits, checkpoints and rewind to undo changes, and claude -c or -r to continue or resume previous sessions.

Lesson 2.4โฑ 7 min read๐Ÿšฒ Getting goingโ“ 3-question quiz
The short answer

Claude Code saves checkpoints so you can rewind conversation and code with Esc twice or /rewind, and git gives you a permanent safety net. Use claude -c to continue your last session and claude -r to pick an older one to resume.

Git: your permanent undo button

Git is a version-control system: it takes snapshots ("commits") of your project so you can always go back. If you're new to it, Claude Code is a brilliant teacher:

Initialise git for this project and make a first commit
Show me what changed since the last commit
Commit these changes with a clear message
Create a new branch called booking-form
Analogy: commits are save points in a video game. Branches are parallel save files where you can experiment without risking the main game.

Checkpoints and rewind

Claude Code automatically tracks checkpoints of the edits it makes during a session. If things go sideways:

  • Press Esc twice (or use /rewind) to jump back to an earlier point.
  • Choose whether to restore the conversation, the code, or both.
Note: checkpoints cover Claude's own file edits. They are not a replacement for git: changes made by commands it runs (or outside Claude) may not be reversible this way. Commit often.

Continue and resume sessions

Closed the terminal? Your conversation isn't lost.

claude -c     # continue the most recent conversation in this folder
claude -r     # pick from a list of previous sessions to resume

You can also use /resume from inside a session. This is handy for picking up yesterday's work with all its context intact.

A safe working rhythm

  1. Start on a fresh branch for each feature.
  2. Let Claude work in small steps.
  3. Review the diff, run the app or tests.
  4. Commit when happy. Rewind or reset when not.
  5. Ask Claude to open a pull request when the feature is done (if you use GitHub).

This rhythm turns AI-assisted coding from "hope it works" into a controlled, reviewable process, which is exactly what clients and teams want to see.

Check yourself

Three quick questions to check it stuck.

Ask the tutor

Stuck on something in this lesson? Ask the AI tutor. It answers from this lesson and points you to others that help. Answers are written by AI and can be wrong. Do not include personal details, passwords or company secrets.

Frequently asked

How do I undo changes in Claude Code?

Press Esc twice or use /rewind to restore an earlier checkpoint of the conversation and/or code. For permanent safety, commit your work with git so you can always roll back.

How do I resume a previous Claude Code session?

Run claude -c to continue the most recent conversation, or claude -r to choose an older session from a list. /resume works inside a session too.

Does Claude Code know how to use git?

Yes. It can initialise repositories, write commit messages, create branches, resolve simple merge conflicts and explain git concepts clearly.