git中忽略掉已经add过的文件
巴扎黑
巴扎黑 2017-05-02 09:28:21
0
3
551
  1. 描述你的问题
    有开发过程中,有些文件当时没有当初没有忽略掉,添加到 git 中了(配置文件config.php),现在要从git中进行删除。

  2. 贴上相关代码
    $git rm --cached /config/config.php

  3. 贴上报错信息
    fatal: Could not switch to 'D:/Program Files (x86)/Git/config/': No such file or directory

执行命令 git 直接从命令所在的目录进行解析路径了,而没有从仓库目录开始解析路径,所以才出现这个问题。
以前用过这个命令是不有问题的,想知道如何解决?

巴扎黑
巴扎黑

reply all(3)
巴扎黑

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:

git rm -r --cached . #删除追踪状态
git add . 
git commit -m "fixed untracked files"
大家讲道理

/config/config.phpIt is not the file in the config directory in the current directory, but the config directory in the root directory

changed to

git rm --cached ./config/config.php

The dot represents the current directory

Of course, it’s okay if you don’t add ./, the default is the current directory

为情所困

Follow the above method and it will prompt that the file cannot be found in the index

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!