When .gitignore
doesn’t work, after removing local git cache, it works properly.
git rm --cached -r .
This command means to remove caches in this working directory recursively. If you want to remove caches of a specific directory selectively, then you can specify the directory the position of .