title: How to move HEAD to other branch in Git without checking out files or updating any refs?
body: <p>I usually do it by <code>echo ref: refs/heads/new_branch &gt; .git/HEAD</code>. How to do it properly?</p>
  
  <p>Some use cases:</p>
  
  <ol>
  <li>You imported source code from some other location, now want to commit it into Git (but not into current branch).</li>
  <li>Your <code>.git</code> is just a symlink and now you are accessing it from other workdir (I already know about git-new-workdir to do it properly)</li>
  </ol>
  
  <p>Therefore you want to choose manually what parent the next commit should have and what ref should be updated by it.</p>