Как исключить папку .idea из git-репозитория в продуктах JetBrains
Вообще, я не знаю, почему по-умолчанию эти файлы оказываются в репозитории. Они явно не относятся к проекту, а являются служебными для IDE. Этим страдают все программы *Storm, которые я использовал. Включая мои любимые WebStrom и PhpStorm.
Самое первое, что нужно сделать — это удалить уже залитые файлы (если таковые есть) из репозитория. Для этого используется самая обычная команда, выполняемая в папке перокта:
- git — вызов утилиты git’а
- rm — удаляет файлы из отслеживания
- —cached — делает так, чтобы файлы небыли удалены физически с вашего диска. По-умолчанию git rm удаляет выбранный файл/каталог с диска
- .idea — собственно файл или каталог, который вы хотите исключить
Так же, не забывайте, что в корне проекта нужно создать файл .gitignore и добавить туда одну простую строчку:
Как удалить папку .idea из git-репозитория
Очень часто при создании проектов в PhpStorm от компании JetBrains при первом коммите народ по привычке нажимает «ОК» на все вопросы IDE и папка .idea попадает в git-репозиторий, которой там совсем не место. Удаляется оттуда она очень просто.
Суровый русский тимлид. Жил в Магадане, в офисе московских веб студий и в Тульской деревне. Виртуозно знает WordPress, PHP, ООП, Vue.js и вот это вот все.
Делает крутые высоконагруженные сайты, поэтому уже почти захватил весь рынок WordPress разработки в России. Не дает никому делать сайты без спроса.
Accidentally committed .idea directory files into git
I have accidentally committed the .idea/ directory into git. This is causing conflicts everywhere else I need to checkout my repo. I was wondering how do I remove these files from the remote?
I still need these files locally since the Intellij IDE needs them. I just don’t want them in the remote. I have added the directory .idea/ to my .gitignore and committed and pushed this file into remote. This seems to have no effect during my checkout on my other machine though. I still get the error message:
6 Answers 6
Add .idea directory to the list of ignored files
First, add it to .gitignore , so it is not accidentally committed by you (or someone else) again:
Remove it from repository
Second, remove the directory only from the repository, but do not delete it locally. To achieve that, do what is listed here:
Send the change to others
Third, commit the .gitignore file and the removal of .idea from the repository. After that push it to the remote(s).
Summary
The full process would look like this:
(optionally you can replace last line with git push some_remote , where some_remote is the name of the remote you want to push to)
You can remove it from the repo and commit the change.
After that, you can push it to the remote and every checkout/clone after that will be ok.

Its better to perform this over Master branch
Edit .gitignore file. Add the below line in it.
Remove .idea folder from remote repo. using below command.
Stage .gitignore file. Using below command
git commit -m ‘Removed .idea folder’

if you haven’t push to git
if "git rm .idea/ -r —cached" throw an error "fatal: pathspec ‘.idea’ did not match any files" and already push to git with .idea on it.

You should add a .gitignore file to your project and add /.idea to it. You should add each directory / file in one line.
If you have an existing .gitignore file then you should simply add a new line to the file and put /.idea to the new line.
After that run git rm -r —cached .idea command.
If you faced an error you can run git rm -r -f —cached .idea command. After all run git add . and then git commit -m «Removed .idea directory and added a .gitignore file» and finally push the changes by running git push command.
Удалить файл из контроля версий в IntelliJ IDEA
Я использую IntelliJ IDEA Community Edition 2016.1. Я разместил свой проект под Git, разместил его на GitHub.
Когда я впервые нажал кнопку Поделиться проектом на GitHub , каждый отдельный файл был выбран для помещения под контроль версий.
Теперь я хочу исключить IML-файл модуля из системы контроля версий. Незаметно, я хочу сохранить его на своем жестком диске. К сожалению, я не могу найти способ сделать это. Как мне этого добиться?
Я пытался удалить его из веб-интерфейса, но при извлечении/нажатии я получаю фатальные ошибки.