无效的原因是:对应的目录或者文件已经被git跟踪,此时再加入.gitignore后就无效了,
解决办法:
先执行 git rm -r --cached .idea
再重新加入.gitignore文件
https://stackoverflow.com/questions/9550437/how-to-make-git-ignore-idea-files-created-by-rubymine
Ask Question
up vote94down votefavorite 18 | I use Rubymine for Rails projects. Very often, Rubymine makes changes in .idea/* files that I don't care about. But it keeps preventing me from checking out new branches, and makes my version of .idea/ different from my coworkers. We already added .idea/ to .gitignore , but it keeps tracking changes in .idea . How should I do this the right way? Below is one of typical error messages I got: error: Your local changes to the following files would be overwritten by checkout:
.idea/workspace.xml
git rubymine
|
|
| perhaps you already comitted; you need to git rm; add it to ignore. – Kaan Yy Oct 23 '13 at 6:45 |
add a comment |
16 Answers
activeoldestvotes
up vote124down voteaccepted | just .idea/ works fine for me
|
|
| hi there! wanna tell us more how u do it...ain't working for me? :( – YoniGeek Nov 22 '13 at 13:10 |
| Git works a bit differently than that. See the git man page for more info. – Steve Benner Jan 17 '14 at 13:34 |
| @BradBird I just tried it - works for subfolders as well. Also you may want to give a try to **/.idea/ – the_joric Oct 13 '14 at 12:15 |
| Part of the issue is if you've already staged your stuff, the .gitignore will not help. – Dan Rosenstark Oct 16 '14 at 4:23 |
| But if you want to ignore files/folders after you added/checked in them then you need to remove them with "git rm -r --cached web/uploads" (in this example i added "web/uploads" folder to .gigignore file after they were checked in) source: help.github.com/articles/ignoring-files – Dung Jan 28 '16 at 20:45 |
show 3 more comments |
up vote138down vote | Try git rm -r --cached .idea in your terminal. It disables the change tracking.
|
|
| The most useful answer out there! – Alex Kyriakidis Feb 18 '16 at 2:44 |
| This answer should be accepted as correct answer! – Vadim Guzev May 24 at 12:18 |
add a comment |
up vote28down vote | Note that JetBrains recommends tracking all but two of the the .idea/* files
For better collaboration between project team you should put under the version control all the files under .idea directory in the project root except the workspace.xml and tasks.xml fileswhich store user specific settings. (How to manage RubyMine projects under Version Control Systems)
So you should probably only ignore the workspace.xml and tasks.xml files
|
|
| While I agree with this answer [+1'd for correctness], I think teams who aren't strict with IDEs and such can get away with not checking in the .idea folder at all... It's never made sense to me anyway, files in there always conflict for reasons that make no sense. – JaKXz Sep 7 '14 at 8:26 |
| It is a bad practice to commit IDE specific files. One reason is that different developers may use different tools. Another one is that those files may contain user specific configuration which will get conflict all the time.– Jordan Silva May 2 '16 at 9:40 |
| This recommendation is a bad practice. Using it in a project is the best way to version files that contain user specific information such as absolute path... Just look inside your .idea folder before following this reco. – JBE Jan 5 at 17:22 |
add a comment |
up vote22down vote | Add .idea/* to your exclusion list to prevent tracking of all .idea files, directories, and sub-resources.
|
| add a comment |
up vote20down vote | if a file is already being tracked by Git, adding the file to .gitignore won’t stop Git from tracking it. You’ll need to do git rm the offending file(s) first, then add to your .gitignore. Adding .idea/ should work
|
| add a comment |
up vote11down vote | In the rubymine gui, there is an ignore list (settings/version control). Maybe try disabling it there. I got the hint from their support guys.
|
| add a comment |
up vote8down vote | using git rm -r --cached .idea in your terminal worked great for me. It disables the change tracking and unset a number of files under the rubymine folder (idea/) that I could then add and commit to git, thus removing the comparison and allowing the gitignore setting of .idea/ to work.
|
| add a comment |
up vote6down vote | Close PHP Storm in terminal go to the project folder type git rm -rf .idea; git commit -m "delete .idea"; git push;
Then go to project folder and delete the folder .idea sudo rm -r .idea/
Start PhpStorm and you are done
|
| add a comment |
up vote5down vote | Add .idea to ~/.gitignore_global and follow the instructions here to get .gitignore_global working: Git global ignore not working Then you don't have to ever add it to an individual .gitignore file. |