Blog / git
Coding agent stopped mid-rebase: finish it or back out
Your agent left a rebase, merge or cherry-pick half done. Read what git status says, then continue or abort, and get back any commits it made meanwhile.
On this page
- Read what git status says
- Why everything else fails
- Option 1: back out
- Option 2: finish it
- The agent kept committing mid-rebase
- In a worktree
- --skip and --quit
- Stop it happening again
- Where Joxo fits
- Frequently asked questions
- How do I know if a rebase is in progress?
- Does git rebase --abort lose my work?
- Why can't I switch branches during a rebase?
- How do I find the files that still have conflicts?
- What's the difference between git rebase --abort and --quit?
- How do I finish a merge my agent left half done?
- Try it with your team
Your agent started a rebase, hit a conflict, and stopped. Maybe it ran out of turns, maybe you pressed Esc, maybe it moved on to something else. Now git switch fails, git branch shows no branch, and you're not sure whether finishing or backing out loses anything. Neither does, if you take it one step at a time. We ran every command with git 2.43 on a test repository.
Read what git status says#
Start here every time. The first lines tell you which operation is half done:
git statusinteractive rebase in progress; onto ba8f41e
Last command done (1 command done):
pick b790a6e Use port 4000
Next command to do (1 remaining command):
pick 6017e2f Docs
You are currently rebasing branch 'agent/port' on 'ba8f41e'.
(fix conflicts and then run "git rebase --continue")
(use "git rebase --skip" to skip this patch)
(use "git rebase --abort" to check out the original branch)
Unmerged paths:
both modified: config.txtThat tells you a lot: the agent was rebasing agent/ onto main, the first of two commits stopped on a conflict in config.txt, and one commit is still waiting.
For a merge or a cherry-pick, the wording changes:
You have unmerged paths.
(fix conflicts and run "git commit")
(use "git merge --abort" to abort the merge)You are currently cherry-picking commit b790a6e.
(fix conflicts and run "git cherry-pick --continue")A revert that stopped says "You are currently reverting commit …", with git revert --continue and --abort in the same places.
Why everything else fails#
While a rebase is in progress, you're not on your branch. git branch shows it:
* (no branch, rebasing agent/port)
agent/port
mainAnd git won't let you leave:
fatal: cannot switch branch while rebasing
Consider "git rebase --quit" or "git worktree add".So you have to settle the rebase one way or the other before you can carry on with anything else in this folder.
Option 1: back out#
If you didn't ask for the rebase, or you'd rather handle the conflict yourself later, abort:
git rebase --abort
git log --oneline -36017e2f Docs
b790a6e Use port 4000
6fb20e6 initThe branch is exactly as it was before the rebase started. Nothing the agent committed before it began is lost. The same goes for git merge --abort and git cherry-pick --abort.
Option 2: finish it#
If the rebase was what you wanted, resolve the conflict and let git carry on. List the files that still need you:
git diff --name-only --diff-filter=Uconfig.txtOpen each one, keep the right lines, delete the <<<<<<<, ======= and >>>>>>> markers, then:
git add config.txt
git rebase --continueSuccessfully rebased and updated refs/heads/agent/port.If more commits conflict, git stops again and you repeat. A merge finishes with git commit instead; once every conflict is added, git status says "All conflicts fixed but you are still merging."
Before you continue, search for leftover markers so they don't end up in a commit:
git diff --cached | grep -nE '^\+(<{7}|={7}|>{7})'No output means you're clear. If they already landed, see conflict markers in a commit.
The agent kept committing mid-rebase#
Agents don't always recognise the state they're in. A common one: the agent resolves the conflict and runs git commit instead of git rebase --continue. The commit goes onto the detached rebase head, not your branch:
git log --oneline -2d2a9530 Agent: resolve port
ba8f41e Use 8080If you now abort, that commit disappears from view. It isn't gone. The reflog still has it:
git reflog -46017e2f HEAD@{0}: rebase (abort): returning to refs/heads/agent/port
d2a9530 HEAD@{1}: commit: Agent: resolve port
ba8f41e HEAD@{2}: rebase (start): checkout main
6017e2f HEAD@{3}: checkout: moving from main to agent/portTake it back with git cherry-pick d2a9530, or save it on a branch with git branch agent-resolve d2a9530. The same applies to anything an agent commits on a detached HEAD.
If you'd rather keep going instead, git rebase --continue carries on from where it stopped, and the agent's extra commit stays in the rebased branch.
In a worktree#
Each worktree has its own rebase state, so git status inside it is still the place to look. To see where git keeps it:
git rev-parse --git-path rebase-mergeIn the main checkout that prints .git/rebase-merge; in a worktree it points under .git/. Don't delete that folder by hand. --abort cleans it up and puts your branch back; deleting it leaves you on a detached head with half the commits applied.
--skip and --quit#
Two more options appear in the hints. Use them with care:
git rebase --skipdrops the commit that conflicted and moves on. That commit's changes are gone from the result. Only use it when you're sure the commit isn't needed, for example whenmainalready has the same fix.git rebase --quitstops the rebase but leaves you wherever it got to, on a detached head, with no branch updated. It's rarely what you want;--abortis the safe exit.
Stop it happening again#
- Tell the agent to finish or abort. Put a line in its instructions file (CLAUDE.md, AGENTS.md): "If a rebase, merge or cherry-pick stops on a conflict, resolve it and continue, or abort; never leave one in progress."
- Prefer merge for shared branches. A rebase that stops after five commits is harder to reason about than a single merge with one conflict. If you're not sure, ask agents to merge
maininto their branch. - One agent per folder. A second agent in the same folder sees a rebase it didn't start and may "fix" it. Give each one its own worktree.
- Check status first. Ask agents to run
git statusbefore any git command and stop if it says an operation is in progress.
Where Joxo fits#
A rebase that stalls on your teammate's agent is invisible to you until it blocks something. With Joxo, each agent on a project reports when it's stuck and needs a person, and that shows up on the desktop app and your phone. Setup is one line pasted into your agent.
Frequently asked questions#
How do I know if a rebase is in progress?#
Run git status. It starts with "interactive rebase in progress" or "You are currently rebasing", and git branch shows "(no branch, rebasing <branch>)".
Does git rebase --abort lose my work?#
No. It puts the branch back exactly as it was before the rebase. Commits made during the rebase are kept in the reflog and can be cherry-picked back.
Why can't I switch branches during a rebase?#
Git refuses with "cannot switch branch while rebasing" because the rebase isn't finished. Run git rebase --continue or git rebase --abort first.
How do I find the files that still have conflicts?#
Run git diff --name-only --diff-filter=U. It lists every file still marked as unmerged.
What's the difference between git rebase --abort and --quit?#
--abort puts your branch back as it was before the rebase. --quit stops the rebase where it is and leaves you on a detached head, without restoring the branch.
How do I finish a merge my agent left half done?#
Resolve each conflicted file, git add it, then run git commit. Or run git merge --abort to undo the merge.