Saint - Cyr MAPOUKA
Saint - Cyr MAPOUKA

Reputation: 452

The right .gitignore file for Symfony3

Using Symfony3, when a I do git status , I get

modified:   .gitignore
modified:   var/cache/dev/profiler/index.csv
modified:   var/logs/dev.log

I don't understand why because, this is my .gitignore file content:

/var/
!var/cache/.gitkeep
!var/logs/.gitkeep
/app/config/parameters.yml
/phpunit.xml
/vendor/
/web/bundles/

source: Knp University

Upvotes: 1

Views: 1105

Answers (2)

tobiasvl
tobiasvl

Reputation: 580

is your question why it says that var/cache/dev/profiler/index.csv and var/logs/dev.log are marked as modified when they should be ignored by the first line in .gitignore?

Git only applies ignore patterns to untracked files. You can't ignore changes to files that git already track.

If you want to remove the files from the git repository, use git rm. To keep the local versions of the files, use git rm --cached.

If what you want to do is keep the files tracked, but also have a local version of the files that git shouldn't care about, see https://gist.github.com/canton7/1423106 for some possible workarounds.

Upvotes: 0

Vampire
Vampire

Reputation: 38629

If a file once is tracked it will keep tracked. .gitignore just has effect on untracked files. You can not ignore changes to already tracked files. So if you want those files not tracked anymore, remove them from the repository in addition to adding them to .gitignore. If you want to keep the local copy use git rm --cached.

Upvotes: 2

Related Questions