title: When is it that I have to stash local changes in git while switching branches?
body: <p>This is a follow up question to the question I posted earlier today, I am a git newbie and I am trying to under the functioning of git branches.</p>
  
  <p>I am getting the </p>
  
  <blockquote>
    <p>Please, commit your changes or stash them before you can switch branches error .<br/></p>
  </blockquote>
  
  <p>Here is my git set up</p>
  
  <blockquote>
    <p>I create a file file1 in the branch Master, and  than I add and commit it.<br/>
    I create a branch b1 and switch to that, Over there I make a few changes to file1 and commit it..<br/>
    I switch back to master, where I make a few changes and I don't commit it..<br/>
    Now when I try to switch to b1, I get the error shown above..<br/></p>
  </blockquote>
  
  <p>My question is that what are factors that are causing this error? What is it that git is seeing to throw this error.</p>
  
  <hr>
  
  <p>Consider this scenario of a separate project</p>
  
  <blockquote>
    <p>I create a file temp in the branch Master, and  than I add and commit it.<br/>
    I create a branch 'branch1', now branch1 has a copy of temp file.<br/>
    I make a few changes in temp file in Master and don't commit it.<br/></p>
  </blockquote>
  
  <p>Now when I try to switch to branch1, why is it that it is not throwing that error? From my understanding both of the scenarios are similar. But it throws that error in the first scenario not the second one?</p>
  
  <p>SO Can anyone explain to me, what are the parameters that govern the switching between windows?</p>