One thing that works for me is to check out another branch, especially if it's very different from the current one. After that, just go back to the branch you were working on.
I don't know why, but sometimes I need to repeat this process a few times to solve it.