Extremely long list of worktree/branches makes it impossible to select when starting new chat

I was experiencing an EXTREMELY annoying issue with antigravity after the latest update where I can’t scroll the list of worktrees making it impossible to see what you are selecting.

Incomplete list after minimizing screen as much as I am allowed to using CTRL (-)

After a many attempts of trying to fix this I was able to finally figure it out. I had the agent summarize what we did to fix it in case others are experiencing the same issue:

How to Fix Ghost Worktrees & Overflowing Worktree Dropdown in Google Antigravity

The Problem

If you frequently create and delete worktrees in Google Antigravity, you might run into an issue where:

  1. Ghost Worktrees Remain: The worktree / branch picker in Antigravity continues to list dozens (or hundreds) of old, deleted worktrees.
  2. “Workspace doesn’t exist” Error: Selecting any of those ghost entries results in an error stating the workspace cannot be found.
  3. UI Overflow / Trapped UI: Because the dropdown renders every worktree you’ve ever made, the menu becomes so long that it extends past the top of the monitor. As a result, the + Work in a New Worktree button at the very top is cut off and completely inaccessible, preventing you from starting new chats in new worktrees.
  4. Standard Git Cleanups Don’t Work: Running git worktree prune, deleting local/remote branches, clearing .git/info/refs, or clearing conversation histories does not remove them from the UI.

Root Cause

Antigravity does not query Git directly for this menu. Instead, it tracks project environments in an internal configuration file located at:

  • Windows: C:\Users\<YourUsername>\.gemini\config\projects\<project-uuid>.json
  • macOS / Linux: ~/.gemini/config/projects/<project-uuid>.json

Every time a worktree is created in Antigravity, an entry is added to the "environments" array in that JSON file. Deleting the worktree folder or running Git commands does not clean up this registry, so the list grows indefinitely until the menu overflows the screen.


The Fix (Step-by-Step)

1. Locate Your Project’s JSON Configuration

Navigate to your config directory:

  • Windows: C:\Users\<YourUsername>\.gemini\config\projects\
  • macOS / Linux: ~/.gemini/config/projects/

Inside, you will find files named with UUIDs (e.g., xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.json). Open them in any text editor and check the top lines to find your project name:

{
  "id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
  "name": "YourProjectName",
  ...
}

2. Back Up the File

Make a copy of the .json file before editing it (e.g., project-config.json.bak).

3. Clean the environments Array

Look for the "environments" block. In affected projects, this list will have dozens or hundreds of stale entries:

"environments": {
  "environments": [
    {
      "id": "11111111-1111-1111-1111-111111111111",
      "name": "stale_worktree_1",
      "resources": { ... }
    },
    {
      "id": "22222222-2222-2222-2222-222222222222",
      "name": "stale_worktree_2",
      "resources": { ... }
    }
  ]
}

Edit the "environments" array so it only contains the worktrees you actively still have on disk. For example:

"environments": {
  "environments": [
    {
      "id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
      "name": "active_worktree_name",
      "resources": {
        "resources": [
          {
            "folderUri": "file:///path/to/your/active/worktree"
          }
        ]
      }
    }
  ]
}

(If you have no active worktrees you wish to keep, you can simply set "environments": []).

4. Save and Reload Antigravity

  1. Save the .json file.
  2. In Antigravity, open the Command Palette (Ctrl+Shift+P on Windows/Linux, Cmd+Shift+P on macOS).
  3. Run Developer: Reload Window (or restart the app).

The ghost entries will disappear, the dropdown will return to normal size, and + Work in a New Worktree will be right at the top again.


Additional / Related Troubleshooting Notes

  • Pruning Git worktrees: Run git worktree prune inside your repository to clean up Git’s own internal worktree tracking.
  • Windows MAX_PATH Errors: Deleting old worktrees with deep build directories (such as Android build caches or node_modules) may fail with Filename too long. Use Python with the extended path prefix (\\?\C:\...) or robocopy /purge to cleanly delete stubborn directories.
  • Git Info Refs: If old remote or branch references keep lingering in Git completions, check .git/info/refs in your main repository and delete it if it contains obsolete references.