After git rebase origin/main, the error says cannot rebase, you have unstaged changes.

Something got messed up after I moved from Linux to Windows. After cloning my Learning repo, I couldn’t refresh my local repo for a directory I had in gitignore.

$ git rebase origin/main
error: cannot rebase. You have unstaged changes.
error: Please commit or stash them

There were changes I did not want to keep for a file called This didn’t work

$ git restore

It got stuck on the same error message.


$ git rm --cached
$ git commit -m "Untrack"

Then rebase again

$ git rebase origin/main
Successfully rebased and updated refs/heads/...