Search code examples
gitgithubgit-remote

Added an existing project to github and got a "* [new branch] master -> master"


was following the instructions here to add an existing project to github. I did a git push origin master and got: * [new branch] master -> master.

I do not recall seeing this before. Is this normal?

Edit 1:

ray@rays8350 /cygdrive/d/ray/allEclipseProjects/eclipseworkspaces
$ git remote show origin
* remote origin
  Fetch URL: https://github.com/rtayek/eclipseworkspaces.git
  Push  URL: https://github.com/rtayek/eclipseworkspaces.git
  HEAD branch: master
  Remote branch:
    master tracked
  Local ref configured for 'git push':
    master pushes to master (up to date)

ray@rays8350 /cygdrive/d/ray/allEclipseProjects/eclipseworkspaces
$ git remote -vv
origin  https://github.com/rtayek/eclipseworkspaces.git (fetch)
origin  https://github.com/rtayek/eclipseworkspaces.git (push)

ray@rays8350 /cygdrive/d/ray/allEclipseProjects/eclipseworkspaces
$ git branch -vv
* master 8112d8f added license.

ray@rays8350 /cygdrive/d/ray/allEclipseProjects/eclipseworkspaces
$ git branch -a
* master
  remotes/origin/master

ray@rays8350 /cygdrive/d/ray/allEclipseProjects/eclipseworkspaces
$

Solution

  • Yes, it's normal.

    More precisely, this is normal when the other Git repository—the one over on GitHub, in this case—did not have the branch name that you just told it to make. It has now made the branch name. Since you created the GitHub repository as a totally empty repository, with no commits and no branch names in it, that repository could not possibly have had the branch name you told it to use. So it had to create it as a new branch name.

    Note that in any Git repository, Git itself has to obey a strict constraint: each branch name, in that repository, must hold the (single) hash ID of some valid, existing commit. This means that a new, empty repository cannot have any branch names, because it has no commits. For this reason, GitHub offers to create each new repository with one initial commit in it, with that one initial commit holding a README file, a LICENSE file, and so on. The instructions you linked tell you to avoid that, so that the one initial commit won't be in your way.

    By avoiding the initial commit, you avoid this headache (of dealing with that initial commit) which gets you instead a different headache: a repository with no branches. But the instructions go on to tell you how to make that empty repository become non-empty, so that it can now have branch names.