title: How to avoid getting into detached head state in git?
body: <p>I am getting into detached state head state all the time. I don't know why and I don't know what it is.</p>
  
  <p>Every time I am trying to recover from this state, I am loosing some files (from last commit I did in detached head state).</p>
  
  <p>Is it possible to avoid this state completely or it is by design?</p>