BuildGist

How to undo Codex changes

Kayvan Zahiri ·

The Codex CLI has no undo command: its slash-command list, checked on October 17, 2026, has no /undo and no /rewind. To undo a run, choose Revert all, or revert one file or one hunk, in the Codex app's review pane, or put the files back with Git: git restore for edits nobody committed and git revert for commits.

Where /undo went

If you remember typing /undo in Codex, you are not imagining it. In January 2026 a user reported it missing after an update (openai/codex issue #8804, since closed). A request for a /rewind that puts back both the chat and the code Codex edited is still open (issue #11626).

What Escape twice does, and does not do

Press Esc twice with an empty composer and Codex lets you edit your previous message, then forks the chat from that point. That rewinds the conversation. Codex's documentation does not say it restores any files, and the author of issue #11626 writes that it does not revert code changes made after that point.

So treat it as a way to ask again, not a way to undo. The files Codex already edited stay edited, and the re-asked turn starts from that changed code. Put the files back first, then edit the message.

Undo in the Codex app

The app's review pane shows the run's diff with Git actions on it. Codex's code review documentation, read on October 17, 2026, lists three levels you can revert or stage at:

The docs sum it up as staging what you want to accept and reverting what you want to discard. That makes a partial undo easy: keep the hunks that were right, revert the one that was not.

When one part is wrong, a fix can be cheaper than an undo. Hover over the line in the review pane, select +, write what is wrong, and send a follow-up message that says what to do with it. The docs suggest something like "Address the inline comments and keep the scope minimal."

Undo in the CLI, with Git

Start by looking. Inside Codex, /diff shows staged changes, unstaged changes and files Git is not tracking yet. In the project folder, the same picture:

git status
git diff --stat

You can run every command below without leaving Codex: prefix the line with ! and it runs as a local shell command under your current approval and sandbox settings.

Edits nobody committed

git restore path/to/file
git restore .

The first puts one file back as it was at the last commit, or as you staged it. The second does it for every tracked file under the current folder, including any edits of yours, so check git status first. If something is staged, git restore --staged on it comes first.

Files Codex created are untracked, and git restore does not touch them. List them with git clean -n, which deletes nothing, then remove the ones that are Codex's by hand or with git clean -f once the list holds nothing you want.

To set the attempt aside instead of deleting it, git stash --include-untracked keeps it, new files and all, and git stash pop brings it back later.

Commits Codex made

Codex sometimes commits during a run, and a commit is not in git diff anymore. Find the run's commits and undo them with new commits:

git log --oneline -5
git revert <commit>
git revert --no-commit <oldest-commit>^..HEAD

The second line undoes one commit. The third undoes a range in one go and leaves the result for you to check and commit. Both keep history intact, which matters once the branch is pushed.

Make the next undo easy

Which of these is your situation

Know what you are throwing away

Before you revert a run, read it. Read sign-in, deletion, payments, new dependencies and configuration first. The full read is in how to review what Codex changed, and the same job in Claude Code, which does have a rewind, is in how to undo Claude Code changes.

BuildGist explains each meaningful Claude Code, Cursor and Codex run in plain English and flags concerns, so you can see what a run did before you keep it or throw it away. BuildGist does not undo anything. The review pane and Git do that. The explanation is written by AI, so check important behavior against the code and tests.

Sources

What you need

Codex needs you to approve BuildGist once, in Codex. BuildGist shows the steps. Setup is in Getting started.

To explain a run, your computer sends BuildGist what that run needs, and BuildGist passes it to Anthropic. BuildGist does not keep this material. It does not send your whole repository, files the run did not change, or files named like secrets, such as .env files and keys. It keeps the explanation and short cited excerpts of changed code, at most 12 lines each. Secret masking is best-effort. Privacy has the full list.

Every account gets 7 days of BuildGist Pro free, with no card. The 7 days start at your first explanation or Continue handoff. Nobody is charged when the trial ends. After that, BuildGist Pro is $12 per month, plus any applicable tax shown at checkout. See pricing.

Try BuildGist

Apple silicon, macOS 12 or later. United States, 18 or older.

Related

Questions: kayvanandre@gmail.com.