Gitignore does not ignore .idea directory

Working on a Symfony2 project using phpStorm IDE, I added a couple of files to git to ignore, but one file, despite the fact that it is added to git, is ignored, always appears .... I tried many 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 this is the .idea folder / files that git simply 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 just won't ignore the whole directory, as I specyfied in gitignore ...?

+19
source share
3 answers

Git never ignores changes in tracked files. Since it is displayed as modified, the file is under version control (the idea / workspace.xml file usually should not be), and therefore changes are tracked in it. Remove it from the index, leaving your local copy unchanged git rm --cached .idea/workspace.xml and commit this change. From now on, it will be ignored unless you add it back to the repository or change the gitignore settings.

+29
source

After you commit the file, it will start tracking .
To delete a file from now on, you must delete them from the repository.

Now you need to delete the entire .idea folder, commit the deletion, add the idea extension to the .gitignore file.

Note

You can still ignore the added files with the assume-unchanged flag

--[no-]assume-unchanged

When this flag is specified, object names recorded for paths are not updated.
Instead, this option sets the / unsets bit to "assume unchanged" for paths.

When the assume unchanged bit is enabled, the promises user does not modify the file and allows Git to assume that the working tree file matches what is written in the index.

If you want to modify the working file of the tree, you need to clear the bit to tell Git.

Git will fail (elegantly) if you need to modify this file in the index, for example. when merging in fixation; thus, in case the alleged-unprocessed file is modified upstream, you will need to manually handle the situation.


Explaining how to do this from the command line can also be done through IDEA.

 # Remove the file from the repository git rm --cached .idea/ # now update your gitignore file to ignore this folder echo '.idea' >> .gitignore # add the .gitignore file git add .gitignore git commit -m "Removed .idea files" git push origin <branch> 
+15
source
 #idea folder .idea/ 

It worked fine for me

0
source

Source: https://habr.com/ru/post/1247864/


All Articles