How to .gitignore folder

30 December 2024

What to do if you want to ignore a specific directory and all it's content.

If you want to ignore a directory named logs, your .gitignore file should include:

logs/

If the directory was already tracked by Git, you need to untrack it before it will be ignored. Use the following command:

git rm -r --cached directory_name

Then commit the changes:

git commit -m "Stop tracking directory_name"

After this, Git will ignore the specified directory and its content.