Possible Duplicates:
git: Switch branch and ignore any changes without committing.
Git branches behaving strangely
I know that the general recommendation is to have a clean status before switching branches in git. ( stash or park-commit ). I'm trying to understand when will I get "You have local changes cannot switch branches" , I can't follow the logic :
I have a repo, with a file called version.txt, contains the text "1" :
git checkout -b new
echo 2 >> version.txt (working dir is not dirty, modified the file)
git checkout master ( how come this works ? I have not stages\commited my changes on new )
same happens if I delete the file content in my new branch, or stage the file first.
Can someone help me to understand when will i get the "You have local changes cannot switch branches." ?
Thanks, Ran