This question is about the apparent inconsistency in git behavior. It is not about how to solve "Cannot pull with rebase" -- that I already know.
We've all been in this situation: make some local changes, and when preparing to commit realize that we're in the wrong branch. So we need to switch branch first:
git checkout master
git pull
My question is this: sometimes I get the message "error: Your local changes to the following files would be overwritten by checkout:" right when doing the checkout; some other times, checkout works, I see some merging being done on the modified files, but then the message "Cannot pull with rebase: You have unstaged changes"is given when doing the pull. Why is the error not always given on checkout, or always on pull?