Rubymine: How to make Git ignore .idea files created by Rubymine

GitRubymine

Git Problem Overview


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 Solutions


Solution 1 - Git

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

Solution 2 - Git

just .idea/ works fine for me

Solution 3 - Git

Note that JetBrains recommends "If you decide to share IDE project files with other developers...", tracking all the .idea/* files except for the following:

  • workspace.xml
  • usage.statistics.xml
  • tasks.xml
  • the shelf/ directory

So to follow their advice, you would add those 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 and the shelf directory which store user specific settings > - ... >
How to manage projects under Version Control Systems (archive)

There's some additional notes and discussion on that page that you should read if you're considering going ahead with this,
including additional files you may want to gitignore even if you decided you want to share IDE files (e.g. .iml files, .idea/modules.xml, gradle.xml, user dictionaries folder, additional files that are generated from gradle or maven).

Solution 4 - Git

Add .idea/* to your exclusion list to prevent tracking of all .idea files, directories, and sub-resources.

Solution 5 - Git

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

Solution 6 - Git

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.

Solution 7 - Git

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

Solution 8 - Git

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

Solution 9 - Git

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

Solution 10 - Git

Add .idea to ~/.gitignore_global and follow the instructions here to get .gitignore_global working:

https://stackoverflow.com/questions/7529266/git-global-ignore-not-working

Then you don't have to ever add it to an individual .gitignore file.

Solution 11 - Git

For me there was only one solution to remove .idea folder than commit file .gitignore with ".idea" and than use IDE again

Solution 12 - Git

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.

Solution 13 - Git

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 :)

Solution 14 - Git

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!

Solution 15 - Git

What about .idea/* ? Didn't test, but it should do it

Solution 16 - Git

JetBrains has a .gitignore_global on GitHub.

Solution 17 - Git

For all JetBrains IDEs:

Settings > Editor > File Types > Ignored Files and Folders, press + sign and add .idea to ignored list.

Alternatively, add to .gitignore (for committing) or .git/info/exclude (for local) the line .idea/.

Solution 18 - Git

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

Solution 19 - Git

If you've already made an initial commit and you have .idea files showing up as new files in git, you will need to remove the files first and then commit them. The following steps will do the trick

 1. git rm --cached -r .idea/
 2. Add .idea/ to **.git/info/exclude** or **.gitignore**
 3. git commit -m 'ignore .idea/ files'

It's explained in detail in this link here: https://devconnected.com/how-to-clear-git-cache/

Solution 20 - Git

.gitignore, which is a file used to explicitly specify which files or folders should be ignored by Git

The ignore rules specified in $HOME/.gitignore_global, $HOME/.config/git/ignore, $GIT_DIR/info/exclude, .gitignore are all in effect in the Git repository

A .gitignore file explicitly specifies which files should not be tracked by Git, i.e., ignored by Git. Files that were already tracked by Git before being gitignore are not affected by the gitignore rule.. To stop tracking a file that is already tracked by Git, use the git rm --cached .idea/ command

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionAdamNYCView Question on Stackoverflow
Solution 1 - GitPetr SyrovView Answer on Stackoverflow
Solution 2 - Gitthe_joricView Answer on Stackoverflow
Solution 3 - GitDarynView Answer on Stackoverflow
Solution 4 - GitPerceptionView Answer on Stackoverflow
Solution 5 - GitappsmaticsView Answer on Stackoverflow
Solution 6 - GitGMarxView Answer on Stackoverflow
Solution 7 - GitGustavo MaimoneView Answer on Stackoverflow
Solution 8 - GitmanavortexView Answer on Stackoverflow
Solution 9 - GitPromise PrestonView Answer on Stackoverflow
Solution 10 - GitfosriasView Answer on Stackoverflow
Solution 11 - GitIvan PetkevichView Answer on Stackoverflow
Solution 12 - GitSteve BennerView Answer on Stackoverflow
Solution 13 - GitWilliemView Answer on Stackoverflow
Solution 14 - GitfrisinachoView Answer on Stackoverflow
Solution 15 - GitksolView Answer on Stackoverflow
Solution 16 - GitJeff WolskiView Answer on Stackoverflow
Solution 17 - GitqwrView Answer on Stackoverflow
Solution 18 - GitMir-IsmailiView Answer on Stackoverflow
Solution 19 - Gitbenitta.ruphusView Answer on Stackoverflow
Solution 20 - GitmarieView Answer on Stackoverflow