vscode .gitignore cannot take effect after adding new files

  1. The reason is that you have already submitted and included README.md into the project before adding .gitignore (or adding README.md to the file). Git will keep tracking this file in the future.
  2. If you change to ignore files ending in .md in .gitignore and submit, then create a new md file, it will definitely not be tracked.
  3. [Without changing the .gitignore file] To solve this problem, execute the first step below, and then submit. The README.md file will not be tracked in the future.
git rm --cached readme1.txt # 删除readme1.txt的跟踪,并保留在本地。
git rm --f *.txt # 删除readme1.txt的跟踪,并且删除本地文件。

Guess you like

Origin blog.csdn.net/Defiler_Lee/article/details/120873222