Git rebase fails because of uncommitted changes, but there are no uncommitted changes

Posted on Oct 26, 2024

Recently I got the following error when I was doing a git rebase master:

error: Your local changes to the following files would be overwritten by checkout:
      <Omitted list of files>
Please commit your changes or stash them before you switch branches.
Aborting
error: could not detach HEAD

git status showed no unstaged changes, and I confirmed that there were no changes in .gitignored files."

Normally, it helped to execute the following on the branch-to-rebase:

git reset -- hard

Ensure that no uncommitted changes exist, as they may otherwise be lost.

Recently, however, this approach didn’t work, so I’m documenting it here.

The following steps helped me solve the issue:

git switch master
git rebase master branch-to-rebase

Want to know more?

Keep on reading and choose one of the related articles. You can also check the home page for my latest thoughts, notes and articles.