Last Updated: January 17, 2019
· antony492

Git - Error: pathspec 'develop' did not match any file(s) known to git.

Ever get this message when you are certain that the branch you are trying to pull exists? Even after you do a fetch, git pull origin develop just doesn't work?

Well first do:

git show-ref

This shows all of the branches you have references to. If you see the one you are trying to pull in this list do the following command:

git checkout -t -b develop origin/develop

This will successfully create a new branch on your local and fill it with all the stuff in the origin.

4 Responses
Add your response

I have resolved the issue as follow
git checkout develop
Error: pathspec 'develop' did not match any file(s) known to git

(Develop is branch name)


git show-ref

This will show the SHA ID of all the branchs including develop

cat .git/refs/head/develop

In my case the SHA ID in refs/head/develop didnt match with the git show-ref results.

echo XXXXXXX(SHA ID) > .git/refs/head/develop

solved the issue.

over 1 year ago ·

Do you know why just plain "git checkout feature/branch_name" doesnt work?

over 1 year ago ·

I think this error typically happens when there's either no matching branch_name in your locally fetched repos, OR there's multiple clones of the branch, so git doesn't know which you're trying to checkout on the initial branch creation.

So a slight mod to the tip is:
git checkout -t -b develop origin/develop

The origin/develop is the starting point for the newly created branch, so you could do any such examples:
git checkout -t -b develop another_repo/develop

over 1 year ago ·

@coderp Thx man, it's working for me

over 1 year ago ·