This means that, yes indeed, there is no branch named master
. There's no requirement that any Git repository have any particular branch names—you can have a repository with no branch names at all—so that's not an error, unless of course you want it to be one.
Use git branch
to list out all the existing branch names. In a new, empty repository, this would print no names as there are no branches, but your git status
output indicates that you do at least have one branch name, specifically new
.
Use git branch -r
to list out all the existing remote-tracking names. That should make you ask: wait, what's a remote-tracking name? (Especially since Git calls this a remote-tracking branch name: I drop the word branch because these names aren't actually branch names at all.) A remote-tracking name is the way your Git remembers some other repository's branch names.
The key insight here is that your branch names are yours. They are not anyone else's branches. Just as your name might be Sue, or Rajeesh, or Quentin, or whatever, that doesn't mean that everyone named Sue (or whatever your name may be) is you. Your Git repository has its own branch names. You may want yours to match up with someone else's, but that's just a desire on your part, not something Git must do.
When you have your Git—your Git software operating on your Git repository—talk to some other Git (software on another repository), the two Gits will confer, and your Git will be able to see their commits and their branches (to whatever extent they're willing to show them anyway). Your Git will get their branches-and-commits when you run git fetch
. But your Git will turn their branch names into your remote-tracking names, so that if they have a branch named fred
, you get a remote-tracking branch with some other name.
In order to have your Git talk to another Git, you will set your Git up with what Git calls a remote. A remote is just a short name like origin
: we have Git store a URL under this shorter name, and then we run:
git fetch origin
to direct our Git to look up the short name, origin
, find the long URL (ssh://git@github.com/some/path/to/repo.git
or https://github.com/some/path/to/repo.git
or whatever), and connect there and see their branches and commits.
Having seen origin
's branch named fred
, if your Git is directed to bring it over—that's the default—you will then find, in your repository, the remote-tracking name origin/fred
. This represents the branch name fred
as seen on the remote named origin
.
The git branch -r
command lists out these remote-tracking names. Using git branch -a
, your Git will list out your branch names and your remote-tracking names, so that you will be able to see your new
and—if it exists at this point—your origin/fred
. For whatever reason,1 git branch -r
prints this one as origin/fred
and git branch -a
prints it as remotes/origin/fred
.
Now, you might want your Git to create a new branch name, and you can do that. You should, however, first read up on how commits and branch names actually work. Git uses the names only2 to find commits: it's really the commits and their hash IDs (or "object IDs", to be formal) that matter.
1This is just plain inconsistent. Both forms work: you can write either origin/fred
or remotes/origin/fred
, if you like. But there's no solid reason for this difference in output format. The actual full name origin/fred
is refs/remotes/origin/fred
, and if one is going to go to the effort to insert the remotes/
part, why not go all the way and put in the unambiguous refs/remotes/origin/fred
version? But that's all just an aside.
2Well, mainly is more accurate than only, since branch names also participate in key-value lookups for branch.*
settings in your configuration.