I\'m not sure why I\'m unable to checkout a branch that I had worked on earlier. See the commands below (note: co
is an alias for checkou
Three steps
I had the same issue for one of my branch.
These commands work for me.
git fetch --all
git checkout <branch-name>
I was getting this error when I tried to checkout new branch:
error: pathspec 'BRANCH-NAME' did not match any file(s) known to git.
When I tried git checkout origin/<BRANCH-NAME>
, I got the detached HEAD:
(detached from origin/)
Finally, I did the following to resolve the issue:
git remote update
git fetch
git checkout --track origin/<BRANCH-NAME>
I copied remote origin url
from another .git/config
file, doing so my new .git/config
file was missing following line in [remote "origin"]
section
fetch = +refs/heads/*:refs/remotes/origin/*
Adding above line fixed error: pathspec 'master' did not match any file(s) known to git.
in my case I enter submodule directory without doing
git submodule init
git submodule update
So git was linked to the parent folder that indeed missed that branch.
I encountered this same issue when I was first playing around with git. When attempting my first commit...
git commit -m 'first commit!'
I got the error mentioned by the OP...
error: pathspec 'commit!'' did not match any file(s) known to git.
I thought I might have been confusing git by using a keyword in the commit message, so I tried a few other words and received the same error.
Finally I used double-quotes in the message...
git commit -m "first commit!"
This turned out to be successful...
[master (root commit) 0000000] first commit!
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 dummyDoc.txt