.gitignore is ignored - content in ignored directories is still included in commits

The .gitignore for our project is similar to the template provided via .gitignore template for Katalon Studio

Here are the exact contents:

settings/*
.DS_Store
/bin/
/Libs/
/.settings/
/.classpath
.svn/
Reports/

However, when changes are made to files in the above locations (specifically with settings and Reports/), those changes are still pushed to git. This leads to having to fix merge conflicts about timestamps in the settings directory in many of our merges.

Is there something we are missing about how .gitignore is setup?

Try the following for your settings and Reports directories:

.settings
/Reports

This has always worked for me.

Let’s say you have already added/committed some files (.settings and Reports) to your git repository and you then add them to your .gitignore; these files will still be present in your repository index.

.gitignore is not effective to those files which were already added to the index. If you want to ignore them, you need to remove those files out of the index.

In order to get rid of .settings and Reports, you need to do the following:

$ git rm -r --cached .settings
$ git rm -r --cached Reports

See http://www.codeblocq.com/2016/01/Untrack-files-already-added-to-git-repository-based-on-gitignore/

1 Like