Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <blockquote> <p>Why isn't <code>FETCH_HEAD</code> checked out right after fetching? Why did it only become checked out after I merged the origin's tracking branch into my local master?</p> </blockquote> <p><code>FETCH_HEAD</code> in itself doesn't reference any branch: it only remember the last fetched SHA1.<br> As it doesn't reference a branch, it isn't really checked out (and shouldn't be checked out), or you would end up with a <strong><a href="https://stackoverflow.com/a/3965714/6309">detached head</a></strong>.</p> <p>However, merging the tracking branch to the <code>master</code> branch will update <code>HEAD</code> (which points to the updated master): that branch is checked out.<br> If the merge is a <a href="https://stackoverflow.com/a/4684404/6309">"<strong>fast-forward</strong>" one</a>, the checked-out branch <code>HEAD</code> and <strong><code>FETCH-HEAD</code> would reference the same SHA1, giving the impression that <code>FETCH_HEAD</code> is "checked out"</strong> (it isn't really)</p> <hr> <p>In other words, in the following picture:</p> <p><img src="https://i.stack.imgur.com/Kfvry.jpg" alt="checked out in Egit"></p> <p><code>FETCH_HEAD</code> has the "checked-out" tick <strong>only because it reference the same SHA1 than the current checked-out branch <code>HEAD</code> (here <code>master</code>)</strong>.</p> <p>That means that, if you do <strong>a new commit</strong>:</p> <ul> <li><code>FETCH_HEAD</code> wouldn't have the checked-out tick anymore (it would still reference the last fetched SHA1). That is why I say it isn't "really" checked-out (in the sense of "it wouldn't <em>stay</em> checked-out after a new commit, since it is a <em>fixed</em> reference to a particular SHA1)</li> <li><code>HEAD</code> and the <code>master</code> branch would reference a new SHA1, and would keep the checked-out tick.</li> </ul> <p>But if you were to check out directly the <code>FETCH_HEAD</code> SHA1 (before merging it to <code>master</code>: <a href="http://wiki.eclipse.org/EGit/User_Guide#.22Detached.22_HEAD" rel="nofollow noreferrer">the Egit User Guide</a> mentions you can do that if the reference isn't already checked-out), then:</p> <ul> <li><code>FETCH_HEAD</code> would still be "checked-out"</li> <li>same for <code>HEAD</code></li> <li>but <code>master</code> (or any other branch) would <strong>not be checked-out anymore</strong>: this is a <a href="https://stackoverflow.com/a/3965714/6309">DETACHED HEAD situation</a></li> </ul> <p>If you were to make a <em>new</em> commit on top of a checked-out <code>FETCH_HEAD</code>:</p> <ul> <li><code>FETCH_HEAD</code> would no longer be checked-out (since it remains fixed on the last fetched SHA1)</li> <li>HEAD would point to the new commit checked-out.</li> <li>no branch would be "checked-out": detached HEAD.</li> </ul> <p>You would need to open that checked-out commit done on top of <code>FETCH_HEAD</code>, and create a branch from there:</p> <p><img src="https://i.stack.imgur.com/lLwFR.png" alt="create a branch"></p> <p>(from the article "<a href="http://eclipsesource.com/blogs/2011/05/29/life-lesson-be-mindful-of-a-detached-head/" rel="nofollow noreferrer">Git Lesson: Be mindful of a detached head</a>")</p> <hr> <p>In conclusion:</p> <p>Each time you see a "checked-out tick" on the <code>FETCH_HEAD</code> reference, it is because <strong>it references the same SHA1 than the ref currently checked out</strong> (either a commit, or a branch).<br> It is <em>not</em> because <code>FETCH_HEAD</code> itself is checked out: it you do a new commit on top of it, it won't be checked out anymore.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload