In the .gitignore file, files under the specified ignored directories will still appear in the push directory when pushing to git. This is because newly created files in ignored directories are cached in git. Even if some files have been included in version control, the ignore paths declared in .gitignore will not take effect.
In this case, we should first delete the local cache, and then proceed with the git push, so that the ignored files will not appear. The command to clear the local cache in git is as follows:
git rm -r --cached .
git add .
git commit -m 'update .gitignore'