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:
- Commit any/all outstanding code commits to the git repository
git rm --cached log/development.log
This removed this file (log/development.log) from the index.git add .
Add the file to the repositorygit commit -m "ignore the log/development.log file"
Commit the file
This should do the task 🙂