I am trying to create a local Git branch, but it is not working. Here are the commands I am using:
tablet:edit11$ git checkout -b edit_11
Switched to a new branch 'edit_11'
tablet:edit11$ git checkout edit_11
error: pathspec 'edit_11' did not match any file(s) known to git.
tablet:edit11$ git branch
tablet:edit11$
What's going on?
You successfully created and "switched to" a branch called
edit_11
when you ranHowever, everything (incl. an empty
git branch
output) indicates that you have just initialised your repository and have yet made to make an initial commit. If there is no commit, branches have nothing useful to point at and there is nothing to check out.Therefore, when you run
you get the following error,
even though branch
edit_11
does exists.The problem can be reproduced as follows:
After you make a first commit on branch
edit_11
,git checkout edit_11
will not longer throw any error. Note that this it is a no-op, here, because the current branch is alreadyedit_11
.The first line creates the new branch and moves you to that branch. You doesn't need to do anymore. Just only use: