As explained in this post git checkout -b <mybranch>
runs two commands simultaneously
git branch <mybranch>
git checkout <mybranch>
I created a new git repository with git init
. Now When I run git branch development
I get the error:
Not a valid object name: 'development'.
If I run git checkout newbranch
. I get the error:
pathspec 'newbranch2' did not match any file(s) known to git.
But if I use git checkout -b BigShotBranch
then it simply creates that local branch with the message:
Switched to a new branch 'BigShotBranch'
so my question is why was the -b
flag able to create the branch while any other method could not? Does the -b
flag only combine two commands or do anything more than that?
P.S: This seems to be a glitch in git. After git checkout -b development
the master branch is actually renamed to development
. There is no master branch now.