Ignoring files after they have been already tracked by Git

It happens sometimes that you start working on a project, setup git, everything is fine, and you switch to a different IDE. As many of you know most IDEs, by default (I know you can manage where to create those files within the IDE), keep some configuration files in hidden folders within your projects root. Now when you do git add . those folders are going to be tracked by git unless they are marked in your gitignore file.

The solution for that:

  • Commit any outstanding code change.
  • Remove the folder from the staging area:
     git rm --cached -r foldername
  • Commit it:
    git commit -m " .gitignore is fine now "

Once that is done your staging area should be clean.

You may also like...