git add 出现问题,pathspec 'readme.txt' did not match any files找不到文件

  1. 在配置git时个别的电脑会出现找不到文件的情况,出现以下错误,看了网上解答都和模糊,然后自己找了下问题,发现了问题所在,以此分享

$ git add readme.txt
fatal: pathspec 'readme.txt' did not match any files
 

git add 出现问题,pathspec 'readme.txt' did not match any files找不到文件
git add 文件出现问题

说明文件是不在的,首先在repository中查看(我的repository地址是C:\Users\账户名\git库名称)。找到添加找不到的文件后,在菜单栏选择【查看】,然后勾选【文件扩展名】选项。

git add 出现问题,pathspec 'readme.txt' did not match any files找不到文件

查看文件名是否正确, 像我的多加了一个.txt后缀,所以会报错,改为正确的名称后,再次git add 就好了。如有问题请私信