Search code examples
gitgitignore

files from folder excluded in .gitignore appears in commits


my .gitignore file contain /var/ folder:

/.idea
/media/
/var/
/errors/

but files from var/cache/ and /.idea appears regularly on new commits.

Yes, I did git init for entire project at the beginning, but also did git rm -r --cached var/ as suggested in https://stackoverflow.com/a/1330097/6827096 but new files still appears. enter image description here


Solution

  • I think it should be, it depends where the gitignore file is. If itś in the same directory as the folders do something like this:

    .gitignore
    .idea
    /media
    /var
    /errors
    

    or:

     .gitignore
     .idea
     media
     var
     errors
    

    I would post this as a comment but I dont have enough rep for that yet.