Why does cloning a remote Git repo create a remote HEAD, when simply tracking does not?

I have Git configurations for participants in a project that are designed to behave the same for me and for all collaborators. So that, for example, our branch names match and the branches track the same remote.

On my end I begin with a Git repo that contains my project and I execute (1)

  • Output to file using GIT in .NET project.json file
  • Git Commands at a Glance
  • Why does cherry-pick tell me that I have all lines changed?
  • Import all of the source code to Bitbucket Git initially
  • Pull non-binary files from git stash
  • Sourcetree adding files in global .gitignore, not in repository .gitignore
  • git checkout -b dev
    git remote add development <dev-repo uri>
    git push --set-upstream development dev

    to create and configure the branches and remote repos that we will use to collaborate. Then I simply instruct my collaborators to (2)

    git clone -o development <dev-repo uri>

    Everything works as expected. In particular, the local repos “look” pretty much identical (which aids communication) — except for one difference: the second configuration, (2), has an additional on branch the remote: development/HEAD. What is this branch and where did it come from? Why is it not present in (1). Does its presence (or absence) have any effect?

  • Can a Rails app be deployed without using Heroku Toolbelt? If so, how?
  • Local git repository - are SSH keys needed?
  • How to do a branch per task strategy with git
  • What does each of the stand for in context of git -p
  • Git infinite loop
  • How to locally test a pull request from gitlab?
  • 2 Solutions collect form web for “Why does cloning a remote Git repo create a remote HEAD, when simply tracking does not?”

    The first part of your question is a dupe.

    Here’s my guess for the second part: When you clone a repo, you’re building a complete repository, including the working directory, from scratch. Without a remote HEAD, git has no idea which branch to check out initially–stated another way, git doesn’t know what your local HEAD should be, it doesn’t know where to get the files for your working directory.

    On the other hand, when you add a remote to an existing repo, you’re adding to something that’s already complete. Git doesn’t have to care which branch the remote would check out by default. You’ve already got a local HEAD, so you don’t need guidance from the remote.

    HEAD is not really a branch it’s a symbolic ref. On the remote it represents its actual branch. You can check what it is with git symbolic-ref refs/remotes/development/HEAD or just simply view the file .git/refs/remotes/development/HEAD.

    When you clone a repository then (by default) that branch will be checked out in your local repository to which the HEAD ref points to on the remote, unless master is on that commit too, because then the master branch is checked out, it has higher priority somehow, at least this was the case a year ago.

    Why it exists in your repository and not in the other one? I don’t know, but it doesn’t really matter.

    Git Baby is a git and github fan, let's start git clone.