fatal: It seems that there is already a rebase-merge directory, and I wonder if
you are in the middle of another rebase. means an earlier rebase stopped (usually
on a conflict) and was never finished. Finish it with git rebase --continue
after resolving the conflict, or cancel it with git rebase --abort; then
start the new rebase.
Run git status first: it says "interactive rebase in progress" and names
the commit it stopped on. Deleting .git/rebase-merge by hand, as the
message also offers, should be the last resort.
The error
PS> git rebase main
fatal: It seems that there is already a rebase-merge directory, and
I wonder if you are in the middle of another rebase. If that is the
case, please try
git rebase (--continue | --abort | --skip)
If that is not the case, please
rm -fr ".git/rebase-merge"
and run me again. I am stopping in case you still have something
valuable there.
Why it happens
A rebase replays your commits one at a time and keeps its plan and progress in
.git/rebase-merge. When a commit does not apply cleanly, Git stops, leaves
that folder in place and waits for you:
PS> git rebase main
Auto-merging price.txt
CONFLICT (content): Merge conflict in price.txt
Rebasing (1/1)
error: could not apply 089cc1a... other price
hint: Resolve all conflicts manually, mark them as resolved with
hint: "git add/rm <conflicted_files>", then run "git rebase --continue".
hint: You can instead skip this commit: run "git rebase --skip".
hint: To abort and get back to the state before "git rebase", run "git rebase --abort".
hint: Disable this message with "git config advice.mergeConflict false"
Could not apply 089cc1a... other price
PS> git status
interactive rebase in progress; onto abdfebd
...
You are currently rebasing branch 'other' on 'abdfebd'.
...
Running git rebase again at that point finds the folder and refuses, since
starting over would throw away the half-done one. The conflict output scrolls past
easily, so the second rebase is often the first thing you notice.
The fix
Read the full git status first. It lists the command it stopped on
(pick 089cc1a other price), the file under "Unmerged paths", and the three
ways out, so you can decide whether the rebase is worth finishing.
Finish the rebase: resolve the file, stage it, continue.
PS> git add price.txt
PS> git rebase --continue
[detached HEAD 16f600f] other price
1 file changed, 1 insertion(+), 1 deletion(-)
Successfully rebased and updated refs/heads/other.
PS> git log --oneline
16f600f other price
abdfebd main price
b969730 first
Or drop it and go back to the branch as it was before the rebase:
PS> git rebase --abort
PS> git status --short
--abort removed the rebase state and left a clean working tree, and the
next git rebase main started normally. The third option in the message,
--skip, was not needed here; Git's own conflict hint describes it as
skipping the commit. The message's rm -fr suggestion is, in its own words,
for when you are not in the middle of another rebase.
How it was reproduced
Git for Windows 2.45.2 on Windows 11, Windows PowerShell 5.1, in a throwaway repository.
Branches main and other changed the same line of
price.txt; on other, git rebase main stopped on
the conflict and a second git rebase main exited with code 128. Both
--abort and, in a second run, resolve plus --continue cleared
the state.
Frequently asked
- How do I fix there is already a rebase-merge directory?
- Run git status to see the rebase in progress. Resolve the conflict, git add the file and run git rebase --continue, or run git rebase --abort to cancel. Then start the new rebase.
- Is it safe to delete .git/rebase-merge?
- Only when no rebase is really in progress. If one is, git rebase --abort is the safe way out because it also puts your branch back where it was.
- Does git rebase --abort lose my work?
- It cancels the rebase and returns the branch to where it was before the rebase started, so your original commits are kept. Only conflict resolutions made during the rebase are discarded.
More decoded errors in the Fixes category. For rebase itself, see rebase, cherry-pick and stash.