I have just created a brand-new git repository:
On branch master
git checkout -b aaa
git checkout master
error: pathspec 'master' did not match any file(s) known to git.
You had no commit in
master branch so,
master does not exist actually.
Create & checkout local
$ git checkout -b master
You can see branch list(s):
$ git branch # see local branch(es) $ git branch -r # see remote branch(es) $ git branch -a # see all local & remote branch(es)
git add -A,
git commit -m 'message'. So, now this commit actually point to the
git init command default branch is
master (it's not real branch, just default git convention). Then without doing any commit you checked out to
aaa branch. So,
master is vanished cause no branch exists without any commit history.