10

I'm trying to add a vim plugin in my settings repo as a git subtree. No matter where I try to pull the subtree to, git replies with an error: pathspec

I'm using the command below while at repos root directory:

git subtree add --prefix .vim/bundle/powerline powerline master --squash

which results in output:

git fetch powerline master
From git://github.com/Lokaltog/powerline
 * branch            master     -> FETCH_HEAD
error: pathspec '.vim/bundle/powerline' did not match any file(s) known to git.

I'm using git version 2.0.3

4
  • This was also happening for me but it turned out to be because the --prefix I was using had a backslash in it... It works for me with regular slash... Sep 10, 2014 at 22:49
  • Have you tried funning git fetch --all before git subtree add ? Sep 10, 2014 at 22:50
  • I tried to setup my repo from scratch. This time everything worked fine. Not sure what was the problem previously, but I think I could have an repo without the initial commit.
    – user917938
    Sep 18, 2014 at 20:37
  • For me (git 2.34.1), it was because the remote repo I added was empty (I had just created it, with intention to fill it). So I had to create a dummy.txt in the remote repo just to get subtree add to work correctly 🙃. Dec 9, 2021 at 11:13

1 Answer 1

28

I had exactly the same problem, turns out it was the "."

 git subtree add --prefix ./cs/ControlLibrary/ ControlLibrary master --squash

Failed with:

error: pathspec './cs/ControlLibrary' did not match any file(s) known to git

but

git subtree add --prefix cs/ControlLibrary/ ControlLibrary master --squash

worked just fine :)

I am on Windows using ConEmu, not sure if that made any difference

1
  • 3
    Similar problem in linux, removing the ./ from the prefix solved it.
    – Daniel
    May 24, 2018 at 17:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.