GIT: error: pathspec 'xxx does not match any file known as git

I have problems with the git repository and I cannot find the error :(

Thing is, I had this repository which is already used for the PHP project. everything was great. Then I added a composer to it. Ie, I copied the composer file to the root of the repository, created the .json composer, and used the “composer installation”. Therefore, composer.lock and the provider / were created for me.

Since I didn't want those to be included in the repo, I added the following to .gitignore

composer
composer.lock
vendor/

Now when I use "git add" oder "git commit" from the root, I will get the following errors:

$ git commit * -m "fixed issue #123"
error: pathspec 'composer' did not match any file(s) known to git.
error: pathspec 'composer.lock' did not match any file(s) known to git.
error: pathspec 'vendor' did not match any file(s) known to git.

Obviously commit (or add) does not work, so I need to manually specify the files to add or commit. Bummer.

:( - , ?

BTW git 2.4.9 (Apple Git -60)

+5
2

, git, . , , . , git commit. -m "xyz" git commit. -m "xyz" git commit. -m "xyz"

git commit -a -m "xyz"

.

.

0

, - , gitignore - . , .

: param git rm

:

( , !!!)

git rm -r --cached .

git add .

git commit -m "hopefully fixed pathspec error"

UPDATE: , :

  • composer, composer.lock, vendor/ .gitignore
  • composer, composer.lock, vendor/
  • , -A, , .
  • composer, composer.lock, vendor/ .gitignore
  • composer, composer.lock, vendor/

- .gitignore, . , pathspec :)

+7

Source: https://habr.com/ru/post/1615228/


All Articles