git .ignore not working in a directory

If your file is already in git before you add the directory to .gitignore git will keep tracking it. If you don't want it, do a "git rm" to remove it first.


Do the following to trigger the gitignore

Step 1: Commit all your pending changes in the repo which you want to fix and push that.

Step 2: Now you need to remove everything from the git index in order to refresh your git repository. This is safe. Use this command:

git rm -r --cached .

Step 3: Now you need to add everything back into the repo, which can be done using this command:

git add .

Step 4: Finally you need to commit these changes, using this command:

git commit -m "Gitignore issue fixed"

The files are already stored in your local commit tree. You'll need to first remove them from the repository. This can be done via:

git rm --cached system/application/config/config.php modules/recaptcha/config/recaptcha.php

After that you'll need to make one more commit and you're good to go.

Tags:

Git