问题
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
回答1:
just .idea/
works fine for me
回答2:
Try git rm -r --cached .idea
in your terminal. It disables the change tracking.
回答3:
Note that JetBrains recommends "If you decide to share IDE project files with other developers...", tracking all the .idea/*
files except the following three files:
- workspace.xml
- usage.statistics.xml
- tasks.xml
So to follow their advice, you would add those 3 files to your .gitignore.
Source:
If you decide to share IDE project files with other developers, follow these guidelines:
...
Here is what you need to share:
- All the files under .idea directory in the project root except the workspace.xml, usage.statistics.xml, and tasks.xml files which store user specific settings
- ...
How to manage projects under Version Control Systems (archive)
There's some additional notes on that page about which other files to gitignore for different specific jetbrains IDEs and builds.
回答4:
Add .idea/*
to your exclusion list to prevent tracking of all .idea files, directories, and sub-resources.
回答5:
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
回答6:
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.
回答7:
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
回答8:
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.

回答9:
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.
回答10:
For me there was only one solution to remove .idea folder than commit file .gitignore with ".idea" and than use IDE again
回答11:
I suggest reading the git man page to fully understand how ignore work, and in the future you'll thank me ;)
Relevant to your problem:
Two consecutive asterisks ("**") in patterns matched against full pathname may have special meaning:
A leading "**" followed by a slash means match in all directories. For example, "**/foo" matches file or directory "foo" anywhere, the same as pattern "foo". "**/foo/bar" matches file or directory "bar" anywhere that is directly under directory "foo".
A trailing "/**" matches everything inside. For example, "abc/**" matches all files inside directory "abc", relative to the location of the . gitignore file, with infinite depth.
A slash followed by two consecutive asterisks then a slash matches zero or more directories. For example, "a/**/b" matches "a/b", "a/x/b", "a/x/y/b" and so on.
Other consecutive asterisks are considered invalid.
回答12:
I tried to added those files into my .gitignore
and it was useless...
Nevertheless, as Petr Syrov said, you can use git rm -r --cached .idea
into your terminal and those files won't be a problem anymore!
回答13:
JetBrains has a .gitignore_global
on GitHub.
回答14:
You may use gitignore for advanced gitignore file generation. It's fast, easy and cutting edge tags are automatically generated for you.
Use this link for most of jetbrains softwares (intelij, phpstorm...) jetbrains .gitignore file
[edit]
Below is the generated gitignore file for Jetbrains Softwares, this will prevent you from sharing sensitive informations (passwords, keystores, db passwords...) used by any of Jetbrains software to manage projects.
# Created by https://www.gitignore.io
### Intellij ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm
*.iml
## Directory-based project format:
.idea/
# if you remove the above rule, at least ignore the following:
# User-specific stuff:
# .idea/workspace.xml
# .idea/tasks.xml
# .idea/dictionaries
# Sensitive or high-churn files:
# .idea/dataSources.ids
# .idea/dataSources.xml
# .idea/sqlDataSources.xml
# .idea/dynamic.xml
# .idea/uiDesigner.xml
# Gradle:
# .idea/gradle.xml
# .idea/libraries
# Mongo Explorer plugin:
# .idea/mongoSettings.xml
## File-based project format:
*.ipr
*.iws
## Plugin-specific files:
# IntelliJ
/out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
Generated code is also well commented. hope it helps :)
回答15:
What about .idea/*
? Didn't test, but it should do it
回答16:
Use .ignore plugin: https://plugins.jetbrains.com/plugin/7495--ignore
It manages a lot of paths/patterns for you automatically and also has many useful extra features. It's compatible with:
- IntelliJ IDEA
- PhpStorm
- WebStorm
- PyCharm
- RubyMine
- AppCode
- CLion
- GoLand
- DataGrip
- Rider
- MPS
- Android Studio
回答17:
While it's not been too long that I made the switch to Rubymine, I found it challenging ignoring .idea files of Rubymine from been committed to git.
Here's how I fixed it
If you've not done any staging/commit at all, or you just spinned up a new project in Ruby mine, then simply do this
Option 1
Add the line below to the .gitignore file which is usually placed at the root of your repository.
# Ignore .idea files
.idea/
This will ensure that all .idea files are ignored from been tracked by git, although they will still remain in your project folder locally.
Option 2
If you've however done some staging/commit, or you just opened up an existing project in Ruby mine, then simply do this
Run the code in your terminal/command line
git rm -r --cached .idea
This deletes already tracked .idea files in git
Next, include .idea/ to the .gitignore file which is usually placed at the root of your repository.
# Ignore .idea files
.idea/
This will ensure that all .idea files are ignored from been tracked by git, although they will still remain in your project folder locally.
Option 3
If you've however done some staging/commit, or you just opened up an existing project in Ruby mine, and want to totally delete .idea files locally and in git, then simply do this
Run the code in your terminal/command line
git rm -r --cached .idea
This deletes already tracked .idea files in git
Run the code in your terminal/command line
rm -r .idea
This deletes all .idea files including the folder locally
Next, include .idea/ to the .gitignore file which is usually placed at the root of your repository.
# Ignore .idea files
.idea/
This will ensure that all .idea files are ignored from been tracked by git, and also deleted from your project folder locally.
That's all
I hope this helps
回答18:
On Windows. Just make the .idea folder hidden. Git will take care of the rest.
来源:https://stackoverflow.com/questions/9550437/how-to-make-git-ignore-idea-files-created-by-rubymine