描述你的问题
有开发过程中,有些文件当时没有当初没有忽略掉,添加到 git 中了(配置文件config.php),现在要从git中进行删除。
贴上相关代码
$git rm --cached /config/config.php
贴上报错信息
fatal: Could not switch to 'D:/Program Files (x86)/Git/config/': No such file or directory
执行命令 git 直接从命令所在的目录进行解析路径了,而没有从仓库目录开始解析路径,所以才出现这个问题。
以前用过这个命令是不有问题的,想知道如何解决?
Sometimes we have submitted the file before adding the .gitignore file. .gitignore can only ignore files that have not been tracked (files that have never been added or committed since they were added). If some files have been included in version management, modifying .gitignore is invalid. Just need to execute:
/config/config.php
It is not the file in the config directory in the current directory, but the config directory in the root directorychanged to
The dot represents the current directory
Of course, it’s okay if you don’t add
./
, the default is the current directoryFollow the above method and it will prompt that the file cannot be found in the index