Warning: Running this will discard local changes. Only run this if you want to discard local changes.
I encountered the same problem and solved it by
git checkout -f branch
and its specification is rather clear.
-f, –force
When switching branches, proceed even if the index or the working
tree differs from HEAD. This is used to throw away local changes.
When checking out paths from the index, do not fail upon unmerged
entries; instead, unmerged entries are ignored.