I’m a git newbie and I keep reading about a “master” branch. Is “master” just a conventional name that people used or does it have special meaning like HEAD?
When I do git branch on the clone that I have, I only see 1 single branch – the one I’m on. No “master” at all. If I type git checkout master (as I see in alot of tutorials or guides), I get
error: pathspec 'master' did not match any file(s) known to git.
I’m just confused as to why my clone doesn’t have a master that everyone seems to imply that it always exists.
Most Git repositories use
masteras the main (and default) branch – if you initialize a new Git repo viagit init, it will havemasterchecked out by default.However, if you clone a repository, the default branch you have is whatever the remote’s
HEADpoints to (HEADis actually a symbolic ref that points to a branch name). So if the repository you cloned had aHEADpointed to, say,foo, then your clone will just have afoobranch.The remote you cloned from might still have a
masterbranch (you could check withgit ls-remote origin master), but you wouldn’t have created a local version of that branch by default, becausegit cloneonly checks out the remote’sHEAD.