title: switching branches in git - when will i get "You have local changes cannot switch branches."?
body: <blockquote>
  <p><strong>Possible Duplicates:</strong><br />
  <a href="https://stackoverflow.com/questions/1304626/git-switch-branch-and-ignore-any-changes-without-committing">git: Switch branch and ignore any changes without committing.</a><br />
  <a href="https://stackoverflow.com/questions/6337122/git-branches-behaving-strangely">Git branches behaving strangely</a></p>
  </blockquote>
  
  <p>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 &quot;You have local changes cannot switch branches&quot; , I can't follow the logic :</p>
  <p>I have a repo, with a file called version.txt, contains the text &quot;1&quot; :</p>
  <blockquote>
  <p>git checkout -b new</p>
  <p>echo 2 &gt;&gt; version.txt  (working dir is not dirty, modified the file)</p>
  <p>git checkout master ( how come this works ? I have not stages\commited my changes on new )</p>
  </blockquote>
  <p>same happens if I delete the file content in my new branch, or stage the file first.</p>
  <p>Can someone help me to understand when will i get the &quot;You have local changes cannot switch branches.&quot; ?</p>
  <p>Thanks,
  Ran</p>