Omniscio

OmniscioGuidesWorktree has unpushed commits

Claude Code: worktree has commits not pushed anywhere

Last checked against Anthropic's documentation on November 22, 2026. By the Omniscio team. Updated .

What is the exact message?

Anthropic's example:

kept 7c5dcf5d — its worktree is still at “/home/you/project/.claude/worktrees/fix-login”
  2 unpushed commits on “claude/fix-login”: a1b2c3d “Fix login flow” and 1 more. They exist on no remote, so deleting the worktree would lose them.
  push them and run 'claude rm 7c5dcf5d' again, or discard the worktree and its commits: claude rm 7c5dcf5d --discard-unpushed a1b2c3d000000000000000000000000000000000@0123456789abcdef0123456789abcdef

When Claude Code cannot summarize the commits, the detail line reads The worktree has unpushed commits instead.

In agent view, the session's row shows not removed with the same reason rather than this block.

Before v2.1.268, claude rm put the commit summary on the kept line itself. When it could not summarize the commits, the kept line read worktree has commits that are not pushed anywhere in place of the summary.

Before v2.1.260, the message did not name the branch or the commits, and there was no discard route.

What does it mean?

A background session in Claude Code can work in its own git worktree. That worktree may hold commits that exist nowhere else, so deleting it would destroy work that no remote has.

This message is the safeguard. Claude Code checked the worktree, found commits it cannot confirm are saved elsewhere, and kept the session instead of deleting it.

Nothing is broken and nothing was lost. The refusal is waiting on one decision: push those commits, or say plainly that the worktree and its commits can go.

How do I fix it?

If you want to keep the commits:

  1. Push them. The message names the branch they are on, such as claude/fix-login. Ask Claude in that session to push it, or run git push -u origin claude/fix-login.
  2. Once the push puts them on a remote-tracking branch, such as origin/claude/fix-login, run claude rm <id> on the session again.

If you do not need the worktree:

  1. First make sure you do not need the worktree, the commits, or any uncommitted changes in it.
  2. Then take the step the message gives: press Ctrl and X together, twice, on the session's row in agent view, or run the claude rm <id> --discard-unpushed <commit>@<worktree-id> command claude rm printed.
  3. If Claude Code refuses again, read the new message and follow it.

If the message says the worktree is also recorded by another finished session, deleting again does not discard it. Push the commits, then try deleting the session again.

On a version before v2.1.260 there is no discard route in the message. You can still delete the session: it loses uncommitted changes but keeps the branch and commits. Run git worktree remove --force --force <path> with the path the refusal printed, then claude rm <id>. Git needs --force twice for a locked worktree.

How do I know it worked?

  • If you pushed, the branch and its commits are on the remote, and deleting the session no longer prints the unpushed-commit block.
  • If you discarded, claude rm removes the row and the worktree, and the session no longer appears in the list.
  • In agent view, a row that reads not removed is still waiting on you; a deleted session is gone from the list.

Where these answers come from

Common questions

Why did claude rm keep my session?

Its worktree holds commits Claude Code cannot confirm are saved anywhere else, so deleting the worktree would lose them.

How do I delete the session anyway?

Either push the commits and run claude rm again once they are on a remote-tracking branch, or run the claude rm --discard-unpushed command the message printed after checking you do not need the work.

What does --discard-unpushed do?

It tells claude rm to discard the worktree and the commits the message lists. The printed command carries the commit and the worktree's id, so the discard names exactly what it destroys.

What does not removed mean in agent view?

It is the same refusal in the session list: the row was kept for the same reason, and the same two ways forward apply.