gemini-cli - 💡(How to fix) Fix [bug] worktree should not be created in the project directory root [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
google-gemini/gemini-cli#26127Fetched 2026-04-29 06:35:35
View on GitHub
Comments
0
Participants
1
Timeline
1
Reactions
0
Author
Participants
Timeline (top)
labeled ×1

Code Example

> /about
╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                                                                                                 │
About Gemini CLI│                                                                                                                                                                                 │
CLI Version                                                  0.39.1Git Commit                                                   4d73f3413                                                                                                          │
Model                                                        Auto (Gemini 3)Sandbox                                                      no sandbox                                                                                                         │
OS                                                           win32                                                                                                              │
Auth Method                                                  Signed in with Google (REDACTED)Tier                                                         Gemini Code Assist StandardGCP Project                                                  REDACTED│                                                                                                                                                                                 │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
RAW_BUFFERClick to expand / collapse

What happened?

I working with worktrees experimental feature (gemini -W) and found a potential issue.

By default, gemini -W created a directory in .gemini/worktrees/... of the current directory. If an instance of Gemini CLI run in the root directory, it can run some script or command that affect worktree contents.

For example, a command that find and replace on all the files.

What did you expect to happen?

I expect gemini -W to created a directory outside the current git directory. Maybe in ~/.gemini/worktrees/<<...>> or ../<<...>>.

An other solution may be to have a setting for that.

Client information

<details> <summary>Client Information</summary>

Run gemini to enter the interactive CLI, then run the /about command.

> /about
╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                                                                                                 │
│ About Gemini CLI                                                                                                                                                                │
│                                                                                                                                                                                 │
│ CLI Version                                                  0.39.1                                                                                                             │
│ Git Commit                                                   4d73f3413                                                                                                          │
│ Model                                                        Auto (Gemini 3)                                                                                                    │
│ Sandbox                                                      no sandbox                                                                                                         │
│ OS                                                           win32                                                                                                              │
│ Auth Method                                                  Signed in with Google (REDACTED)                                                                                   │
│ Tier                                                         Gemini Code Assist Standard                                                                                        │
│ GCP Project                                                  REDACTED                                                                                                           │
│                                                                                                                                                                                 │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
</details>

Login information

Signed in with Google Account

Anything else we need to know?

No response

extent analysis

TL;DR

Consider configuring Gemini CLI to use an external directory for worktrees, such as ~/.gemini/worktrees/, to avoid potential issues with commands affecting worktree contents.

Guidance

  • Review the Gemini CLI documentation to see if there's a built-in setting or configuration option to specify the worktree directory location.
  • If no such setting exists, consider submitting a feature request to the Gemini CLI developers to add this functionality.
  • In the meantime, you could explore using a separate directory for your worktrees and managing them manually, although this may not be as seamless as using the gemini -W feature.
  • Be cautious when running commands that may affect worktree contents, especially if you're working in the root directory.

Notes

The issue lacks information on whether the Gemini CLI provides a configuration option for specifying the worktree directory location. Without this information, it's difficult to provide a more specific solution.

Recommendation

Apply workaround: Use a separate directory for worktrees and manage them manually, as this allows for more control over the worktree location and can help avoid potential issues with commands affecting worktree contents.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING