Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gitignore does not ignore .idea directory

Tags:

git

gitignore

Working on a Symfony2 project using phpStorm IDE, I have added couple of files to git ignore but one file despite being added to git ignore is always appearing....I have tried multiple times but its always there

.gitignore file:

/app/config/parameters.yml /bin/ /build/ /composer.phar /vendor/ /web/bundles/ /app/bootstrap.php.cache /app/cache/* !app/cache/.gitkeep /app/config/parameters.yml /app/logs/* !app/logs/.gitkeep /app/phpunit.xml  #IDE metadata **.idea/**  #Bash files run.sh 

And it is the .idea folder/files that git just will not ignore:

On branch develop 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)          modified:   .idea/workspace.xml  no changes added to commit (use "git add" and/or "git commit -a") 

Any idea why git will just not ignore the whole directory like i have specyfied in gitignore...?

like image 773
John Avatar asked Apr 25 '16 11:04

John


People also ask

Should .idea folder be ignored?

ignoring the idea folder is fine as not everyone uses them, and they are not part of your code - you (hopefully) don't need them on production, for instance. ignoring is fine, but removing is less of a good idea. It contains information for your local workspace. I'm surprised this is down-voted.

Why files in Gitignore are not ignored?

gitignore ignores only untracked files. Your files are marked as modified - meaning they were committed in the past, and git now tracks them. To ignore them, you first need to delete them, git rm them, commit and then ignore them.

Can Gitignore ignore a folder?

. gitignore is a plain text file in which each line contains a pattern for files or directories to ignore. It uses globbing patterns to match filenames with wildcard characters. If you have files or directories containing a wildcard pattern, you can use a single backslash ( \ ) to escape the character.


1 Answers

Git never ignores changes to tracked files. As it appears as modified, the file is under version control (the idea/workspace.xml file usually should not be) and thus changes to it are tracked. Delete it from the index, leaving your local copy intact with git rm --cached .idea/workspace.xml and commit this change. From then on it will be ignored unless you force-add it back to the repository or change your gitignore settings.

like image 191
Vampire Avatar answered Sep 28 '22 04:09

Vampire