gemini-cli - 💡(How to fix) Fix Gemini ran git reset --hard HEAD in plan mode with uncomitted changes

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…

Code Example

> /about

╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  │
About Gemini CLI│                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  │
CLI Version                                                                                                                                                       0.38.2Git Commit                                                                                                                                                        b0ed611a0                                                                                                                                                                                                                                                                                                      │
Model                                                                                                                                                             Auto (Gemini 3)Sandbox                                                                                                                                                           no sandbox                                                                                                                                                                                                                                                                                                     │
OS                                                                                                                                                                win32                                                                                                                                                                                                                                                                                                          │
Auth Method                                                                                                                                                       gemini-api-key                                                                                                                                                                                                                                                                                                 │
│                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
RAW_BUFFERClick to expand / collapse

What happened?

Gemini 3.1 pro decided to run git reset --hard HEAD in plan mode, while it was supposed to be planning how to address a review of the current changeset. I have altered policies to allow many things in plan mode to allow for MCP servers, but it should be smart enough to not even try this.

What did you expect to happen?

Gemini, especially pro, to be smart enough to not wipe out all of my changes, regardless of policies.

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.38.2                                                                                                                                                                                                                                                                                                         │
│ Git Commit                                                                                                                                                        b0ed611a0                                                                                                                                                                                                                                                                                                      │
│ Model                                                                                                                                                             Auto (Gemini 3)                                                                                                                                                                                                                                                                                                │
│ Sandbox                                                                                                                                                           no sandbox                                                                                                                                                                                                                                                                                                     │
│ OS                                                                                                                                                                win32                                                                                                                                                                                                                                                                                                          │
│ Auth Method                                                                                                                                                       gemini-api-key                                                                                                                                                                                                                                                                                                 │
│                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
</details>

Login information

No response

Anything else we need to know?

No response

extent analysis

TL;DR

The issue can be mitigated by re-evaluating and adjusting the policies in plan mode to prevent Gemini from executing potentially destructive commands like git reset --hard HEAD.

Guidance

  • Review the current policies in plan mode to identify why git reset --hard HEAD was allowed to run, and adjust them to prevent similar incidents in the future.
  • Consider adding specific restrictions or safeguards for critical Git commands in plan mode to ensure Gemini's behavior aligns with expectations.
  • Evaluate the MCP server configurations and their interaction with Gemini's plan mode to ensure compatibility and safety.
  • Test the adjusted policies with a controlled environment or a non-critical repository to verify the changes do not introduce unintended behavior.

Example

No specific code example can be provided without more details on the policies or configurations used.

Notes

The solution depends on the specific policies and configurations in place, which are not fully detailed in the issue. Adjustments should be made with caution to avoid disrupting the normal functioning of Gemini and MCP servers.

Recommendation

Apply workaround: Adjust policies in plan mode to restrict potentially destructive commands, as the current behavior is not aligned with the expected smart handling of changesets by Gemini Pro.

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

gemini-cli - 💡(How to fix) Fix Gemini ran git reset --hard HEAD in plan mode with uncomitted changes