Files that have been added are ignored in git
巴扎黑
巴扎黑 2017-05-02 09:28:21
0
3
577
  1. Describe your problem
    During the development process, some files were not ignored at the time and were added to git (configuration file config.php). Now they need to be deleted from git.

  2. Paste the relevant code
    $git rm --cached /config/config.php

  3. Paste the error message
    fatal: Could not switch to 'D:/Program Files (x86)/Git/config/': No such file or directory

Executing the command git parses the path directly from the directory where the command is located, instead of parsing the path from the warehouse directory, so this problem occurs.
I have used this command before without any problems. I want to know how to solve it?

巴扎黑
巴扎黑

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