TL;DR: The 30-Second Fix
The most reliable way to clear this error is to move your current work to a temporary storage area, finish the rebase, and then pull your changes back. Run these three commands:
git stash
git rebase origin/main
git stash pop
If you don't need your local changes at all, you can wipe the slate clean with git reset --hard. Just be careful—this permanently deletes any work you haven't committed.
Why Git blocks your rebase
Git is acting as a safety net. When you rebase, Git "unwinds" your commits and reapplies them one by one onto a new base. This process often involves modifying the same files you are currently working on.
If you have unstaged changes in app.js and the rebase also needs to update app.js, Git won't risk overwriting your unsaved work. Since these changes aren't in Git's database yet, losing them would mean they are gone forever. Git forces you to decide what to do with those files before it touches the commit history.
Approach 1: Using Git Stash (The Gold Standard)
Most developers prefer stashing because it’s non-destructive. Think of git stash as a clipboard for your file system. It takes your uncommitted modifications and puts them on a stack, leaving you with a clean 100% synchronized working directory.
- Put changes aside:
git stash - Perform your rebase:
git rebase origin/develop - Re-apply your work:
git stash pop
If git stash pop triggers a conflict, it simply means your stashed work and the new rebased commits changed the same lines of code. Open your editor, resolve the markers, and continue as usual.
Approach 2: The 'Set It and Forget It' Autostash
If you find this error annoying, you can automate the entire stashing process. Since Git 1.8.4, the --autostash flag has allowed Git to handle the stashing and popping for you automatically.
git rebase origin/main --autostash
To make this the default behavior for every rebase you ever perform, run this global configuration command:
git config --global rebase.autoStash true
This is a huge quality-of-life improvement. It saves you from typing three commands when one will do.
Approach 3: The WIP (Work In Progress) Commit
Sometimes you might have a dozen modified files and want a more permanent record than a stash. In this case, create a temporary "WIP" commit. This keeps your work safely inside the Git tree.
git add .
git commit -m "wip: saving my place"
git rebase origin/main
Once the rebase is done, you can "undo" that temporary commit but keep the file changes by running git reset HEAD~1. This puts the changes back into your working directory as unstaged files.
Approach 4: Cleaning the Workspace
If the changes preventing your rebase are just accidental edits or debug console.log statements, just delete them. For modern Git (version 2.23 and newer), use the restore command:
git restore .
For older versions, the syntax is slightly different:
git checkout -- .
Verification: Confirming a Successful Rebase
How do you know everything is back to normal? Check these three things:
- Check the tree: Run
git log --oneline --graph. Your commits should now follow the latest commit from the target branch in a straight line. - Check the status:
git statusshould show no "rebase in progress" messages. - Check the stash: If you used Approach 1, run
git stash list. If the pop was successful and there were no conflicts, the stash should be gone.

