zcozuq
Last Updated: February 25, 2016
·
43.37K
· antony492
P4 colour jpg

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.

Say Thanks
Respond

3 Responses
Add your response

13002
0 iioqnmy56hkvha0ytwdjnrs66x39ehmy37ojnrxujcz6bumo7dve4uivhdtdif7tghhzmy3r5pba

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

(Develop is branch name)

Solution:

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 ·
17504

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

over 1 year ago ·
17597
8a125c41536bbd2e5a7f1ba8d6edf46f

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 ·
Filed Under