You can ignore files in git from being added to the repository by putting a
.gitignore file into place. It might however happen that the
.gitignore file seems not work. This is the case if you have already included the files in the git repository index.
To resolve the issue, you can perform these commands in your project directory containing the
$ git rm -r --cached . $ git add . $ git commit -am "Remove ignored files"
- First, remove all the files from the git index. Don’t worry, this does not remove the actual local files.
- Then add back all files. The
.gitignorefile controls that git does not add the files to ignore.
- Finally, commit the changes.