git
rebase_error
ai_generated
true
error: cannot rebase: You have unstaged changes. Please commit or stash them.
ID: git/cannot-rebase-unstaged-changes
95%Fix Rate
95%Confidence
150Evidence
2015-01-01First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 2 | active | — | — | — |
Root Cause
Git refuses to rebase because there are uncommitted changes in the working tree. Rebase rewrites commits and needs a clean working directory to avoid losing changes.
genericWorkarounds
-
95% success Stash changes, rebase, then pop the stash
git stash git rebase origin/main git stash pop # If stash pop has conflicts: git stash drop # after resolving manually
Sources: https://git-scm.com/docs/git-stash
-
92% success Commit the changes as a WIP commit, rebase, then soft reset
git add -A && git commit -m 'WIP: save before rebase' git rebase origin/main git reset --soft HEAD~1 # Your changes are now staged again, rebase is done
Sources: https://git-scm.com/docs/git-reset
Dead Ends
Common approaches that don't work:
-
Using git checkout . to discard all changes before rebase
65% fail
This permanently deletes all uncommitted work. If the changes were important, they are lost forever with no way to recover.
-
Using git rebase --force or --no-verify to bypass the check
95% fail
There is no --force flag for git rebase that bypasses the dirty working tree check. --no-verify only skips hooks, not the clean tree requirement.
Error Chain
Leads to:
Frequently confused with: