Tag Archives: Git

Git: Remove ignored files

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 folder:

$ git rm -r --cached .
$ git add .
$ git commit -am "Remove ignored files"
  1. First, remove all the files from the git index. Don’t worry, this does not remove the actual local files.
  2. Then add back all files. The .gitignore file controls that git does not add the files to ignore.
  3. Finally, commit the changes.

References