I am on branchX
. I make some changes in my working directory. They all get reflected in "Changes not staged for commit".
Now I do git checkout branchY
. Sometimes I get the changes getting moved into "Changes not staged for commit" of the branchY like :
M <some file1 path>
M <some file2 path>
and sometimes git gives me this message - Please commit your changes or stash them before you switch branches.
How does git decide it when to reflect the changes and when to abort ? Should not git never move "Changes not staged for commit" changes of one branch into other if I checkout without committing them ?