.gitignore not ignoring files

I wanted to ignore log/development.log file in my git repository and the first thing which came to my mind was to add it to .gitignore file. So I added the following to my .gitignore file

/log/*.log

This did not help. Why? After a little pondering and googling, I figured out that once a file is part of the git repository, you cannot ignore that file simply by adding to .gitignore.

Solution:

  1. Commit any/all outstanding code commits to the git repository
  2. git rm --cached log/development.log
    This removed this file (log/development.log) from the index.
  3. git add .
    Add the file to the repository
  4. git commit -m "ignore the log/development.log file"
    Commit the file

This should do the task 🙂

 

Leave a Reply

Your email address will not be published. Required fields are marked *

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.