Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Yes, this is normal for new bare (and non-bare) repositories.</p> <h3>Explanation</h3> <p><code>HEAD</code> is what Git calls a <em>symbolic reference</em>&mdash;a reference to another reference.</p> <p>In non-bare repositories, <code>HEAD</code> normally indicates which branch is currently checked out. A new commit will cause the branch named by <code>HEAD</code> to be advanced to refer to the new commit. When <code>HEAD</code> refers to a commit object directly instead of a branch, it's considered to be <em>detached</em>, meaning further commits will not cause a branch reference to be advanced to refer to the new commits (dangerous because checking out a different commit or branch will render the new commits unreachable by any existing reference, making them hard to find and subject to garbage collection).</p> <p>In bare repositories, <code>HEAD</code> indicates the repository's default branch, so that in a clone of the repository <code>git checkout origin</code> is equivalent to <code>git checkout origin/master</code> if <code>master</code> is the default branch (see <code>git help rev-parse</code> for details).</p> <p>When Git initializes a new repository, it initializes <code>HEAD</code> to refer to <code>refs/heads/master</code> (in other words, <code>HEAD</code> points to the <code>master</code> branch by default). However, it does not create a branch named <code>master</code> because there are no commits in the repository for <code>master</code> to point to yet.</p> <p>So until you either create a <code>master</code> branch or change <code>HEAD</code> to point to a branch that does exist, you'll get that error when you run a command that looks at <code>HEAD</code> (such as <code>git log</code> or <code>git show</code> without any arguments).</p> <p>You can still use commands that don't examine <code>HEAD</code>. For example:</p> <pre><code>git log some_branch_that_exists </code></pre> <h3>Fix</h3> <p>To get rid of the error message, you can do one of the following:</p> <ul> <li><p>Change <code>HEAD</code> to point to a branch that does exist:</p> <pre><code>git symbolic-ref HEAD refs/heads/some_other_branch </code></pre></li> <li>Push a new <code>master</code> branch into the repository from somewhere else</li> <li><p>Create a new <code>master</code> branch locally:</p> <pre><code>git branch master some_existing_commit </code></pre></li> </ul> <h3>Visualization</h3> <p>To visualize everything in the repository, I use something like this:</p> <pre><code>git log --graph --oneline --date-order --decorate --color --all </code></pre> <p>Note that the above command will work even if <code>HEAD</code> is pointing to a non-existent branch.</p>
 

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