I have some trouble with a git repository of mine and I cant find the error :(
Thing is, I had this repository already in use for a PHP project. everything was fine. The
I got this issue due to how many levels deep (length) my folders were. The path name was too long and git couldn't handle it, so I took the folder and threw it on my C: and everything started working fine. Check to see if your folder structure is too long. Ex:
C:/folder1/folder2/folder3/..../folder99/file.txt
above is too long, try to make it much shorter.
Something like C:/folder1/folder2/file.txt
(For all files in the repo) and this should fix the issue.
Well, years passed, new git versions were released, yet the problem still show up for me from time to time. The posted fixes unfortunately do not help. Yet, instead of committing with git commit . -m "xyz"
doing a
git commit -a -m "xyz"
does wonders.
Cheers.
I often have this problem if something has changed, added files to gitignore or something else. Maybe you have to rebuild the index.
Updated: added recursive and file param to git rm
In my case this worked:
remove cached files (only the paths are removed from the index, not the real files!!!)
git rm -r --cached .
add all files to the index
git add .
commit
git commit -m "hopefully fixed pathspec error"
UPDATE: If this won't work, try the following:
composer, composer.lock, vendor/
from your .gitignorecomposer, composer.lock, vendor/
outside your repo-A
to add that the files are deletedcomposer, composer.lock, vendor/
to your .gitignore and commitcomposer, composer.lock, vendor/
to your repoNow it should be gone from the repo and due to your .gitignore, never will be commited again. Hopefully the pathspec error is gone :)