PricingSign in52Download

Blog / git

Coding agent stuck waiting for git's editor

An agent ran git commit, rebase or merge and hangs, or fails with 'There was a problem with the editor'. Get it unstuck and make git stop opening one.

On this page
  1. What it looks like
  2. Get it unstuck
  3. Commands that don't need an editor
  4. Longer messages without an editor
  5. Interactive rebase without an editor
  6. Stop git opening an editor for the agent
  7. Check nothing is left half done
  8. Tell the agent too
  9. Where Joxo fits
  10. Frequently asked questions
  11. Why does my coding agent hang on git commit?
  12. What does "There was a problem with the editor" mean?
  13. How do I run git rebase --continue without an editor?
  14. How do I run an interactive rebase from a script?
  15. How do I write a multi-line commit message without an editor?
  16. Try it with your team

Some git commands open a text editor for a message: git commit without -m, git merge that makes a merge commit, git rebase --continue, git rebase -i. You'd type a message and close it. An agent can't, so the command hangs until it times out or fails straight away, depending on how the agent runs its shell. We ran every command with git 2.43 on a scratch repository.

What it looks like#

Usually git starts the editor and waits:

hint: Waiting for your editor to close the file...

Nothing else happens until the agent's command times out. If the editor can't start without a terminal, it quits at once and git gives up instead:

error: There was a problem with the editor 'vi'.
Please supply the message using either -m or -F option.

Get it unstuck#

If the command is still hanging, stop it in the agent (most have an interrupt key), or find the editor and end it:

bash
ps -eo pid,args | grep COMMIT_EDITMSG
11651 /usr/bin/vim …/.git/COMMIT_EDITMSG
bash
kill 11651

The file name tells you what was waiting: COMMIT_EDITMSG for a commit or merge, git-rebase-todo for an interactive rebase. A killed vim leaves a swap file behind, here .git/.COMMIT_EDITMSG.swp, and the next commit would open on an "ATTENTION" screen. Delete it.

Nothing was committed, so the staged changes are still staged. A rebase or merge that was waiting is still in progress, and git status says which. Finish it with the commands below, or cancel it with git rebase --abort or git merge --abort.

Commands that don't need an editor#

Give the message on the command line, or tell git to keep the one it has:

bash
git commit -m "Add login form"
git commit --amend --no-edit
git merge --no-edit search
git revert --no-edit HEAD

git rebase --continue has no --no-edit. Set the editor to a command that does nothing for that one call:

bash
GIT_EDITOR=true git rebase --continue
Successfully rebased and updated refs/heads/search.

true exits straight away, so git uses the message as it stands.

Longer messages without an editor#

Agents often skip the message body because -m feels like one line. -F - reads the whole message from standard input, so a heredoc gives a subject, a blank line and a body:

bash
git commit -F - <<'EOF'
Add login form

Adds the form and its validation. Tests cover empty and
wrong passwords.
EOF
[main 2f0d5f6] Add login form
 1 file changed, 1 insertion(+)

The first line is the subject that git log --oneline shows; the rest is the body. Several -m flags work too, each becoming its own paragraph, but a heredoc keeps line breaks exactly as written. The quotes around 'EOF' stop the shell from expanding anything inside the message.

Interactive rebase without an editor#

git rebase -i opens the list of commits to edit. Its editor is GIT_SEQUENCE_EDITOR, which can be any command that changes the file. To fold every commit after the first into it:

bash
GIT_SEQUENCE_EDITOR="sed -i '2,\$s/^pick/fixup/'" git rebase -i --root
Successfully rebased and updated refs/heads/main.
bash
git log --oneline
4d03fe8 Add login form

--root covers the whole history; use main to cover only the branch's own commits. fixup drops the folded commits' messages. On macOS, sed -i needs an empty argument: sed -i ''.

Stop git opening an editor for the agent#

Git picks the editor from GIT_EDITOR first, then core.editor in its config, then VISUAL and EDITOR. Check what it will use:

bash
git var GIT_EDITOR
vim

Set GIT_EDITOR=true in the environment the agent starts in, and every git command it runs takes the message as it is. Do it in the agent's settings file, a wrapper script, or the shell you start it from:

bash
GIT_EDITOR=true claude

Your own terminal keeps your editor, because the variable is set only for that one process and what it starts. Don't put core.editor = true in your config instead: it applies to you too, and your own git commit would then quit on an empty message.

Check nothing is left half done#

After a hang, the agent may have moved on while a rebase or merge was still open. Its next commands then land in the middle of it. Look before letting it carry on:

bash
git status
interactive rebase in progress; onto 2f0d5f6
Last command done (1 command done):
   pick afaade8 Add search
No commands remaining.

For a merge, the first lines read You have unmerged paths, or All conflicts fixed but you are still merging. Finish it with the commands above that need no editor, or cancel it, before the agent does anything else.

Tell the agent too#

Add to your project instructions: "Always pass -m to git commit and --no-edit to git merge and git revert. Never run git rebase -i." The variable handles what slips through, and the instruction keeps the agent from writing empty messages it can't see.

Where Joxo fits#

A hung command is worse when nobody's watching the agent. Joxo shows each agent's status on a shared board and your phone, and flags the ones that need a person, so a stuck agent gets noticed. Setup is one line pasted into your agent.

Frequently asked questions#

Why does my coding agent hang on git commit?#

Without -m, git commit opens an editor and waits for it to close. An agent can't use the editor, so the command waits until it times out. Pass -m, or set GIT_EDITOR=true for the agent.

What does "There was a problem with the editor" mean?#

Git started the editor, but it quit without a terminal to run in, so there was no message. Give the message with -m or -F, or use --no-edit to keep the existing one.

How do I run git rebase --continue without an editor?#

Run GIT_EDITOR=true git rebase --continue. git keeps each commit's message as it is.

How do I run an interactive rebase from a script?#

Set GIT_SEQUENCE_EDITOR to a command that edits the todo list, such as sed, and GIT_EDITOR=true for any messages, then run git rebase -i.

How do I write a multi-line commit message without an editor?#

Pass the message on standard input with git commit -F - and a heredoc: a subject line, a blank line, then the body. Several -m flags also work, each one becoming its own paragraph.