DEV Community

Aashutosh Poudel
Aashutosh Poudel

Posted on

How to ignore an already tracked *.log file in git

I faced this issue the other day. I didn't put *.log file in the .gitignore file earlier.

The problem: I had already committed a few log files before and so it was already in the git. When I added the git ignore rule for excluding log files it wasn't removed automatically. Turns out for files already checked into git, we first need to untrack those files before we add the rules for ignoring those files.

Command for untracking the file:

git rm --cached FILENAME
Enter fullscreen mode Exit fullscreen mode

Reference: https://stackoverflow.com/questions/4308610/how-to-ignore-certain-files-in-git

Top comments (0)