Fixing “already a rebase-merge directory” Error in Git
git rebase stops with "It seems that there is already a rebase-merge directory" because a record of an earlier rebase (.git/rebase-merge) is still there. Run git status to check the rebase in progress. Then either finish it with git rebase --continue, or cancel it with git rebase --abort. Either way the record is removed, and the next rebase runs.
This error appears when you run git rebase main or git pull --rebase to bring a branch up to date with main, while forgetting that an earlier rebase stopped on a conflict.
I tested on Ubuntu 24.04 with Git 2.43.0 and bash 5.2. I ran the commands with LANG=C so the messages are in English. I omitted the progress lines such as Rebasing (1/2) from the output. I did not test Windows or macOS, the Git integration in editors such as VS Code, or the rebase-apply record that git rebase --apply uses.
- 1. The error message
- 2. .git/rebase-merge is the record of a rebase in progress
- 3. First, check the rebase in progress with git status
- 4. To continue, fix the conflict and use –continue
- 5. To cancel, use –abort to return to the branch before the rebase
- 6. If Git stopped while you were editing the todo list, –abort also restores the state
- 7. If –abort fails because head-name is missing, use –quit
- 8. In a worktree created with git worktree, the rebase-merge directory is in a different place
The error message
In the test environment, I left a rebase stopped on a conflict and ran git rebase main again. It printed the following message and stopped with exit code 128.
$ 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.
The message means: a rebase-merge directory already exists, and you may be in the middle of another rebase. If so, try git rebase (--continue | --abort | --skip). If not, delete the directory with rm -fr ".git/rebase-merge" and run git rebase again. Git stops here in case something valuable is still in it.
With the rebase-merge directory present, git pull --rebase . main and git rebase -i main stopped with the exact same message (for these, I created an empty directory to test). For git pull --rebase, the fetch (the From . line) completed, and it stopped at the rebase step after that.
.git/rebase-merge is the record of a rebase in progress
.git/rebase-merge is the directory that stores how far a rebase has got and what remains to be done while the rebase is stopped. When it stopped on a conflict, the contents were as follows.
$ ls .git/rebase-merge
author-script
done
drop_redundant_commits
end
git-rebase-todo
git-rebase-todo.backup
head-name
interactive
message
msgnum
no-reschedule-failed-exec
onto
orig-head
patch
stopped-sha
Looking inside the files: head-name held the original branch name (refs/heads/feature), onto held the commit on main that the branch was being moved onto, and git-rebase-todo held the list of commits not yet applied.
Git treats the mere existence of this directory as "a rebase is in progress". If you try to start a new rebase, it prints the message above and stops. It does not check whether files such as head-name are all present. In the test environment, creating an empty rebase-merge directory alone produced the same message.
(See where Git 2.43.0 makes this decision in its source and where it prints the message.)
First, check the rebase in progress with git status
The message also suggests rm -fr, but look at git status first. When the rebase is stopped on a conflict, it showed the following.
$ git status
interactive rebase in progress; onto bb94d1f
Last command done (1 command done):
pick d7b5337 featureでメモを変更
Next command to do (1 remaining command):
pick 33f3fbc todoを追加
(use "git rebase --edit-todo" to view and edit)
You are currently rebasing branch 'feature' on 'bb94d1f'.
(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:
(use "git restore --staged <file>..." to unstage)
(use "git add <file>..." to mark resolution)
both modified: memo.txt
no changes added to commit (use "git add" and/or "git commit -a")
This means: the feature branch is being moved onto bb94d1f, and when the first commit was applied, memo.txt conflicted and the rebase stopped. Which command you use depends on whether you want to continue or cancel.

To continue, fix the conflict and use –continue
To finish the stopped rebase, fix the conflicting file, run git add on it, and then run git rebase --continue. According to the official git rebase reference, --continue resumes the rebase after conflicts have been resolved.
In the test environment, I fixed memo.txt, ran git add, and then ran git rebase --continue. The remaining commits were applied and the rebase finished. (I set things up so that no commit-message editor opened.)
$ git add memo.txt
$ GIT_EDITOR=true git rebase --continue
[detached HEAD 78d106a] featureでメモを変更
1 file changed, 1 insertion(+)
Successfully rebased and updated refs/heads/feature.
$ ls .git | grep rebase
$ git rebase main
Current branch feature is up to date.
ls .git | grep rebase printed nothing, so rebase-merge was gone. Running git rebase main again did not error. It printed Current branch feature is up to date.
To cancel, use –abort to return to the branch before the rebase
If you no longer need the rebase, run git rebase --abort. According to the official reference, --abort cancels the rebase and returns HEAD to the original branch.
$ git rebase --abort
$ ls .git | grep rebase
$ git status --short --branch
## feature
$ git log --oneline
33f3fbc todoを追加
d7b5337 featureでメモを変更
02e635b 最初のコミット
rebase-merge was removed, and the feature branch went back to the commits it had before the rebase started. Running git rebase main afterward did not error. The rebase started over from the beginning (in this example, it conflicted again at the same place).
If Git stopped while you were editing the todo list, –abort also restores the state
I also created a case where the Git process was killed with kill -9 while the git rebase -i todo list was open in the editor. pgrep -a git printed nothing, so no Git process was running. Even so, rebase-merge remained, and the next git rebase main stopped with the same message.
git status at this point showed the following. Although nothing had been applied yet, it said "You are currently editing a commit". The branch was still feature, and the commits had not moved.
$ git status
On branch feature
No commands done.
Next commands to do (2 remaining commands):
pick d7b5337 featureでメモを変更
pick 33f3fbc todoを追加
(use "git rebase --edit-todo" to view and edit)
You are currently editing a commit while rebasing branch 'feature' on '554fc51'.
(use "git commit --amend" to amend the current commit)
(use "git rebase --continue" once you are satisfied with your changes)
nothing to commit, working tree clean
Even in this state, git rebase --abort succeeded and removed rebase-merge. Running git rebase main afterward did not error, and the rebase ran to completion.
$ git rebase --abort
$ git rebase main
Successfully rebased and updated refs/heads/feature.
If –abort fails because head-name is missing, use –quit
If rebase-merge has no head-name file, --abort fails. In the test environment, I created an empty rebase-merge directory to try this. git rebase --abort printed a warning that it could not read head-name, which records the original branch name, exited with status 1, and left the directory in place.
$ git rebase --abort
warning: could not read '.git/rebase-merge/head-name': No such file or directory
$ ls .git | grep rebase
rebase-merge
In this case, use git rebase --quit. According to the official reference, --quit stops the rebase without returning HEAD to the original branch, and leaves the index and working tree as they are. In the test environment, --quit removed rebase-merge, and the next git rebase main ran to completion. When I instead deleted the directory with rm -fr ".git/rebase-merge", as the message suggests, the next rebase also ran.
$ git rebase --quit
$ ls .git | grep rebase
$ git rebase main
Successfully rebased and updated refs/heads/feature.
--quit and rm -fr only delete the record of the rebase in progress. They do not restore the branch. When I used either one on a rebase stopped on a conflict, HEAD stayed detached at the commit on main that the branch was being moved onto (bb94d1f), with the message HEAD detached from refs/heads/feature, and memo.txt was still in conflict. If the record of the rebase in progress is intact, finish it with --continue or cancel it with --abort.
After rm -fr, running git rebase main stopped with a different error: "error: cannot rebase: You have unstaged changes." In both cases, the feature branch itself remained at the commit it had before the rebase started (33f3fbc). I was able to return to the original branch by discarding the conflicting working-tree changes with git reset --hard and then running git switch feature. git reset --hard discards working-tree changes, so first confirm that you have nothing you want to keep.
In a worktree created with git worktree, the rebase-merge directory is in a different place
When the same error appeared in a working directory created with git worktree add, the path shown by rm -fr in the message was not .git/rebase-merge. (I replaced the repository path with /path/to/repo.)
$ git rebase feature
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 "/path/to/repo/.git/worktrees/wt/rebase-merge"
and run me again. I am stopping in case you still have something
valuable there.
As described in the DETAILS section of the official git worktree reference, each working directory created with worktree has its own directory under the original repository's .git/worktrees/. The rebase record was stored there as well. You can confirm the location from inside that working directory with --git-path of git rev-parse.
$ git rev-parse --git-path rebase-merge
/path/to/repo/.git/worktrees/wt/rebase-merge
Running the same command in the original repository printed .git/rebase-merge. In a worktree working directory, you can clean up the same way with git rebase --abort. In the test environment, .git/worktrees/wt/rebase-merge was removed, and the working directory returned to its branch (topic).




