I am trying to put session and logs directories into .gitignore
file in my Laravel 10 project, but they are not ignored and are still tracked. I have tried to delete the folders and create them again, but that didn’t work.
I am trying to put session and logs directories into .gitignore
file in my Laravel 10 project, but they are not ignored and are still tracked. I have tried to delete the folders and create them again, but that didn’t work.
2
Answers
First of all check, if you have correct path in your .gitignore file.
Bear in mind, that already committed files, or staged files will not be ignored and you need to remove them from staging area or repository.
Since your directories
session
andlogs
are already tracked, adding them to your .gitignore is not sufficient. You first need to remove them from the index, and make their content untracked once again.Here, I’m assuming that the directories
session
andlogs
are at the top level of your working directory.Once the folders have been untracked, make sure that their corresponding patterns within the gitignore exhibit a trailing slash. This is to make sure that the patterns will match only directories. See the documentation for more details.