The reason why git ignores the file does not take effect~

question

Add config.json to the .gitignore file, hoping that the config.json file will not be submitted after being changed, but it does not work.

reason

The .gitignore file will only 第一次be written to the cache when the project is submitted

If the .gitignore file is not written when the project is submitted for the first time, it will not take effect to add the .gitignore file later.

If the .gitignore file is added when the project is submitted for the first time, and the .gitignore file is modified later, the modified file will not take effect.

Solved - clear git cache

git rm -r --cached .
git add .
git commit -m ".gitignore重写缓存"
git push

Guess you like

Origin blog.csdn.net/qq_43260366/article/details/130197333