An excerpt from the git checkout manpage:
When switching branches, if you have local modifications to one or more files that are different between the current branch and the branch to which you are switching, the command refuses to switch branches in order to preserve your modifications in context.
So, if the modifications don't have anything to do with the differences between the branches (as in your example) it'll let you switch. If the diff between the branches modifies the same file you have, it'll refuse - but you can specify the -m
option to get it to do a three-way merge between current branch, work tree, and new branch (that's where that snippet is from).
To make that description a bit more complete: suppose the diff between master and experimental is only in files A, B, and C. If in your work tree you modify A, you will not be able to check out the other branch. If you modify D, though, you can check out just fine.