Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which files in .idea folder should be tracked by Git?

Unlike Netbeans, in Jetbrains IDEs, the setting files related to user and team are mixed in the same folder that makes it tricky when you need to push them to git.

There is a number of sample git ignore files for these IDEs and https://intellij-support.jetbrains.com/hc/articles/206544839 page on git site.

However, after using them for a months we figure out that it is safer and actually more convenient to do the reverse. I mean ignoring all .idea files and adding only team-related settings explicitly. (instead of adding all and ignoring some).

The main thing that can be shared among developers is code style configs. So, by using IDE auto-reformatting option all the team will follow a consistent style.

Besides that, the question is which other files are recommended to be included and not ignored? Why?

Answer: I came across with this: https://github.com/salarmehr/idea-gitignore

like image 632
Handsome Nerd Avatar asked Apr 04 '17 04:04

Handsome Nerd


People also ask

What is stored in .idea folder?

idea directory contains a set of configuration files (. xml) for your project. These configuration files contain information core to the project itself, such as names and locations of its component modules, compiler settings, etc. If you've defined a data source the file dataSources.

What is the .idea folder Git?

idea folder (hidden on OS X) in the solution root contains IntelliJ's project specific settings files. These include per-project details such as VCS mapping and run and debug configurations, as well as per-user details, such as currently open files, navigation history and currently selected configuration.

Should I git ignore .idea folder?

Yes, but if you want to ignore all of the . idea files you only need to add /. idea/ to your . gitignore file once and forget about it.

What are the .idea files?

Image created by Adobe Ideas, a vector image editing touch app for Android tablets; can include vector objects, layers, color themes, and other graphics; commonly used for quick hand editing before completing final edits with the desktop versions of Photoshop and Illustrator.

Is there a way to ignore all idea files in Git?

Yes, but if you want to ignore all of the .idea files you only need to add /.idea/ to your .gitignore file once and forget about it. Or you can do the same thing in your user .gitconfig and not bother with this dummy folder approach. No idea why this one got downvoted.

What is the difference between tracked and untracked files in Git?

Git has two options in which files or folders may be tracked or untracked in its working directory. We will see the difference between tracked or untracked folders in Git below. The files added and committed to Git in the last commit, Git knows about it, are called Tracked files. These files can be staged, modified, or not. Video Player is loading.

What is the idea folder in IntelliJ?

The .idea folder (hidden on OS X) in the solution root contains IntelliJ’s project specific settings files. These include per-project details such as VCS mapping and run and debug configurations, as well as per-user details, such as currently open files, navigation history and currently selected configuration.

How do I blacklist an idea folder in Git?

Blacklist the .idea folder by adding the “.idea” folder to the .gitignore file in master, then commit this change. and commit this change to your branch. Right click the .idea folder, select “local history,” then revert back to an earlier working version.


2 Answers

Jetbrains has some official guidance on which files should not be checked in, and which files should probably not be checked in, depending on your usage. According to that page, you should check in all files in the .idea directory except:

  • workspace.xml
  • tasks.xml

And probably also:

  • the xml files in the dictionary subdirectory

While the particular answer may depend on your team's particular practices, in my experience, following that guidance generally results in correct separation of user settings and shared project configuration.

Some examples of files that should be shared, according to this guidance:

  • ant.xml, which, if you use Ant to build your project, points IDEA to your build files and configures properties that should be used to build.
  • vcs.xml, which specifies the Version Control configuration for your project
  • encodings.xml, which specifies how IDEA should treat the text files in your project
  • modules.xml, which points IDEA to each of your project's module configuration files, which should also be shared in your VCS.
  • all files under the runConfigurations subdirectory, which tells IDEA what it needs to do to run your application
  • codeStyleSettings.xml, which, as you have alluded to, puts your whole team on the same page in terms of automatic code formatting

Depending on your team's usage, there may be more or less, but those are some of the biggest examples.

like image 155
Matt Leidholm Avatar answered Oct 11 '22 06:10

Matt Leidholm


I prefer not to check in the .idea folder or .iml files at all.

  • If you want to share editor styles, consider using a .editorconfig file, the JetBrains IDEs support these now.
  • For other things, like build settings you could try to lean on your build tool, e.g. use maven or gradle build files to carry specific setups.
  • Obviously there's a bunch of other things that won't be covered, but most of them can be solved by well documented conventions.
like image 40
ninj Avatar answered Oct 11 '22 06:10

ninj