This error occurs when Git detects an incomplete rebase or git am operation. The .git/rebase-apply directory tracks rebase state, and Git prevents new rebases when one is already in progress.
When you see this error, Git is telling you that a previous rebase or `git am` (apply mailbox) operation was started but never completed. Git stores rebase state in a hidden directory called `.git/rebase-apply` to track which commits have been applied and which are pending. This typically happens when a rebase encounters a merge conflict and you forget to resolve it, when you switch branches or close your terminal mid-rebase, or when a system crash interrupts the process. Git refuses to start a new rebase because doing so would overwrite the existing state and potentially lose your work. The error is a safety mechanism—Git wants you to deliberately decide what to do with the incomplete rebase before starting another one.
First, understand what state Git is in by running:
git statusThis will tell you if a rebase is in progress, if there are conflicts to resolve, and what branch you're on. Look for messages like "rebase in progress" or "You are currently rebasing".
If you have previously resolved the merge conflicts or want to continue where you left off:
git rebase --continueIf there are still unresolved conflicts, Git will tell you which files need attention. Open each conflicted file, resolve the markers (<<<<<<<, =======, >>>>>>>), then stage the resolved files with git add <filename> before running --continue again.
If you don't want to continue the rebase and prefer to start fresh:
git rebase --abortThis will cleanly undo the rebase operation, restore your branch to its state before the rebase started, and remove the .git/rebase-apply directory.
If the current commit is causing issues and you want to skip it entirely:
git rebase --skipUse this with caution—the skipped commit's changes will not be included in your rebased branch. This is useful when the commit is already applied or creates an empty patch.
If you see "It looks like git am is in progress" when trying to abort:
git am --abortThe git am command is used to apply patches from mailbox files, and it uses the same .git/rebase-apply directory. Abort it first, then you can proceed with your intended operation.
If none of the above commands work and you're certain you want to abandon the rebase:
rm -rf .git/rebase-applyWarning: Only do this if the standard abort commands fail. This forcefully removes the rebase state without any cleanup. After running this, verify your repository is in a good state with git status and git log.
### Understanding the .git/rebase-apply directory
The .git/rebase-apply directory contains several files that track rebase state:
- head-name: The branch being rebased
- onto: The commit you're rebasing onto
- patch: The current patch being applied
- msg: The commit message for the current patch
### Difference between rebase-apply and rebase-merge
Git uses different directories depending on the rebase strategy:
- .git/rebase-apply: Used by git rebase (default am-based) and git am
- .git/rebase-merge: Used by git rebase -m (merge-based) or git rebase -i (interactive)
If you see an error about rebase-merge instead, the same resolution steps apply but substitute the directory name.
### Preventing this in CI/CD pipelines
In automated environments, always ensure previous rebase state is cleaned up:
git rebase --abort 2>/dev/null || true
git am --abort 2>/dev/null || true### Windows-specific considerations
On Windows, the rebase-apply directory may persist due to file locking. Ensure no Git GUI tools or editors have the repository open, then try the removal command in a new terminal window.
kex_exchange_identification: Connection closed by remote host
Connection closed by remote host when connecting to Git server
fatal: unable to access: Proxy auto-configuration failed
How to fix 'Proxy auto-configuration failed' in Git
fatal: unable to access: Authentication failed (proxy requires basic auth)
How to fix 'Authentication failed (proxy requires basic auth)' in Git
fatal: unable to access: no_proxy configuration not working
How to fix 'no_proxy configuration not working' in Git
fatal: unable to read tree object in treeless clone
How to fix 'unable to read tree object in treeless clone' in Git