git checkout my_branch vs. git checkout origin/my_branch : <p>I was on <code>branch1</code> when I checkout <code>branch2</code> like this (both branches are existing).</p>

<p><code>git checkout origin/branch2</code></p>

<p>then I got a detached head error:</p>

<pre><code>You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.
</code></pre>

<p>But then I just checkout <code>branch2</code> (without <code>origin</code>) then it works ok:</p>

<p><code>git checkout branch2</code></p>

<p>So what's the difference between <code>git checkout</code> with and without <code>origin/</code>; and why there was the <code>detached HEAD</code> error when using <code>origin/</code>?</p>
