Challenges with Git Tooling and State Management in Gemini CLI
What happened?
Gemini consistently encounter difficulties when executing Git commands via the run_shell_command tool, leading to inefficient workflows and persistent repository synchronization issues. Specific problems include:
- Non-interactive Command Limitations: The
run_shell_commandtool is non-interactive. When Git commands (e.g.,git pullwith merge conflicts, git commit without a message and no default editor configured, or git rebase -i) require user input, the command either hangs indefinitely or fails immediately, disrupting the intended workflow. - Ambiguous Error Recovery: While
run_shell_commandprovidesstdoutandstderr, interpreting complex Git error messages (e.g., "stale info," "rejected," "cannot pull with rebase: You have unstaged changes") and formulating the correct subsequent recovery steps is challenging. This often leads to trial-and-error attempts or requires explicit user guidance. - Inadequate State Pre-checks: Gemini frequently attempt Git operations (like
git pullorgit rebase) without sufficiently checking the current repository state (e.g., presence of unstaged changes, current branch's tracking status). This results in predictable failures that could be avoided with more robust pre-execution checks. - Lack of Atomic Git Operations: Gemini's current operational model executes Git commands sequentially. If an intermediate command fails, the entire sequence is broken, and Gemini ack a built-in mechanism to atomically revert or intelligently recover from the partial failure, necessitating manual intervention or complex conditional logic.
git push --force-with-leaseMisapplication: Despite understanding the purpose ofgit push --force-with-lease, Gemini's attempts to use it for rebased branches often result in "rejected" pushes.
What did you expect to happen?
I expected to execute Git commands reliably and efficiently, with the ability to:
- Anticipate and gracefully handle scenarios where Git commands might require user interaction or encounter common state-related issues.
- More accurately interpret Git error messages and autonomously formulate effective recovery strategies.
- Perform comprehensive pre-checks on the Git repository state to prevent command failures.
- Execute multi-step Git operations more robustly, potentially with transactional capabilities or more intelligent recovery mechanisms.
- Successfully synchronize local rebased branches with the remote using
git push --force-with-leasewithout repeated rejections.
Client information
- CLI Version: 0.1.5
- Git Commit: bf873a1
- Operating System: darwin v24.3.0
- Sandbox Environment: no sandbox
- Model Version: gemini-2.5-flash
- Memory Usage: 920.7 MB
Login information
Google Workspace Account
Anything else we need to know?
The challenges with Git tool calling are a significant bottleneck in Gemini's to autonomously manage the codebase. Improving Gemini's understanding and execution of Git commands, especially in complex scenarios like rebasing and remote synchronization, would greatly enhance its effectiveness. The current limitations often lead to repetitive actions and require frequent user intervention to resolve what appear to be fundamental Git operational issues.
Found possible duplicate issues:
- #3357: (0.9002641976037159)
Hello! As part of our effort to keep our backlog manageable and focus on the most active issues, we are tidying up older reports.
It looks like this issue hasn't been active for a while, so we are closing it for now. However, if you are still experiencing this bug on the latest stable build, please feel free to comment on this issue or create a new one with updated details.
Thank you for your contribution!
Found possible duplicate issues:
- #3357
- #5553
If you believe this is not a duplicate, please remove the status/possible-duplicate label.
Those are not duplicates because they are more specific in nature.