.git cannot ignore target, or it does not take effect

In git, if you want to ignore a file and prevent it from being submitted to the repository, you can use the method of modifying the .gitignore file in the root directory.
But sometimes in the process of project development, you suddenly want to put some directories or The ignore rule is added to the file, and it is found that it does not take effect after being defined according to the above method. The reason is that .gitignore can only ignore those files that were not tracked before. If some files have been included in the version management, modifying .gitignore is invalid. Then the solution is to delete the local cache first (change it to an untracked state), and then submit it:

git rm -r --cached .
git add .
git commit -m 'update .gitignore'

ok!!!

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325709103&siteId=291194637