skip to Main Content

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


  1. 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.

    Login or Signup to reply.
  2. Since your directories session and logs 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 and logs are at the top level of your working directory.

    # removing the directories' content from the index
    git rm -r --cached session/ logs/
    

    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.

    If there is a separator at the end of the pattern then the pattern will only match directories

    #other patterns
    
    session/
    logs/
    
    #more patterns
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search