ReynierPM
ReynierPM

Reputation: 18680

.gitignore still tracking files even if I tried to ignore them, why?

I have the following directory structure in a project:

.
├── application
│   ├── ... <more folders & files goes here>
├── config
├── cronjobs
│── ... <more folders & files goes here>
├── oneview_symfony
│   ├── app
│   ├── bin
│   ├── src
│   ├── tests
│   ├── var
│   ├── vendor
│   └── web
├── .gitignore

I am trying to ignore some files and folders and this are the rules I have in my .gitignore file:

oneview_symfony/app/cache/*
oneview_symfony/app/logs/*
!oneview_symfony/app/cache/.gitkeep
!oneview_symfony/app/logs/.gitkeep

oneview_symfony/app/spool/*

oneview_symfony/var/cache/*
oneview_symfony/var/logs/*
oneview_symfony/var/sessions/*
!oneview_symfony/var/cache/.gitkeep
!oneview_symfony/var/logs/.gitkeep
!oneview_symfony/var/sessions/.gitkeep

oneview_symfony/app/config/parameters.yml
oneview_symfony/app/config/parameters.ini

oneview_symfony/app/bootstrap.php.cache
oneview_symfony/var/bootstrap.php.cache
oneview_symfony/bin/*
!oneview_symfony/bin/console
!oneview_symfony/bin/symfony_requirements
oneview_symfony/vendor/*

oneview_symfony/web/bundles/
oneview_symfony/web/uploads/   
oneview_symfony/app/phpunit.xml
oneview_symfony/phpunit.xml
oneview_symfony/build/

oneview_symfony/web/css/
oneview_symfony/web/js/

Having the info above if I run git status I am still seeing files under oneview_symfony/vendor/, why? What I am missing?

Output example for the command above:

    ...
    new file:   oneview_symfony/vendor/zendframework/zendframework1/resources/languages/pt_BR/Zend_Validate.php
    new file:   oneview_symfony/vendor/zendframework/zendframework1/resources/languages/ru/Zend_Validate.php
    new file:   oneview_symfony/vendor/zendframework/zendframework1/resources/languages/sk/Zend_Captcha.php
    new file:   oneview_symfony/vendor/zendframework/zendframework1/resources/languages/sk/Zend_Validate.php
    new file:   oneview_symfony/vendor/zendframework/zendframework1/resources/languages/sr/Zend_Validate.php
    new file:   oneview_symfony/vendor/zendframework/zendframework1/resources/languages/uk/Zend_Validate.php
    modified:   oneview_symfony/web/.htaccess

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

Upvotes: 1

Views: 1697

Answers (1)

Liam Gray
Liam Gray

Reputation: 1129

You have already added these files into your git repo and/or staged the changes.

To remove them from the repo, you can run git rm -r --cache <folder-to-ignore> to remove them from the git cache. (Make sure to include the --cache flag so that it doesn't delete the actual files too!)

If you've simply staged the files, you can instead run git reset to unstage them, and they should stop appearing in the changes list if they've been added to the .gitignore correctly.

Upvotes: 6

Related Questions