phpstorm 的.idea 目录加入.gitignore无效的解决方法

phpstorm 的.idea 目录加入.gitignore无效的解决方法

无效的原因是:对应的目录或者文件已经被git跟踪,此时再加入.gitignore后就无效了,

解决办法:

先执行 git rm -r --cached .idea

再重新加入.gitignore文件

https://stackoverflow.com/questions/9550437/how-to-make-git-ignore-idea-files-created-by-rubymine

how to make Git ignore .idea files created by Rubymine

Ask Question

03091658_unIX.gif

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

shareimprove this question

edited Mar 3 '12 at 22:40

simont

28.4k882109

asked Mar 3 '12 at 22:29

AdamNYC

5,8861563129

 
7 

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

shareimprove this answer

answered Mar 12 '12 at 10:03

the_joric

7,20222342

 
3 

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

2 

@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

11 

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

7 

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

03091702_WXLs.gif

 

up vote138down vote

Try git rm -r --cached .idea in your terminal. It disables the change tracking.

shareimprove this answer

answered Aug 10 '13 at 13:51

Petr Syrov

2,76711024

 
14 

The most useful answer out there! – Alex Kyriakidis Feb 18 '16 at 2:44

1 

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

shareimprove this answer

answered Aug 12 '13 at 21:45

Daryn

2,67912234

 
5 

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

3 

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

1 

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.

shareimprove this answer

answered Mar 3 '12 at 22:42

Perception

60.1k8122152

 

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

shareimprove this answer

answered Jun 11 '13 at 19:28

appsmatics

44959

 

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.

enter image description here

shareimprove this answer

edited Aug 31 '14 at 5:31

Sparhawk

567618

answered Mar 20 '12 at 15:10

manavortex

1112

 

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.

shareimprove this answer

answered Feb 21 '16 at 18:58

GMarx

12414

 

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

shareimprove this answer

answered Jan 28 '16 at 9:19

Gustavo Maimone

6113

 

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.

转载于:https://my.oschina.net/yonghan/blog/1137734

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值