Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to deal with IntelliJ IDEA project files under Git source control constantly changing?

People also ask

How do I get rid of file changes in IntelliJ?

In the Log view select the commit containing the changes you want to discard. In the Changed Files pane, right-click the file that you want to revert and select Revert Selected Changes from the context menu. This results in a new commit that reverses the changes you want to undo.

How do I ignore Unversioned files in IntelliJ?

IntelliJ, however, adds its own mechanism to ignore files:Window "Version Control", Tab "Local Changes", Button "Configure Ignored Files" (on the left).

How do I change Git settings in IntelliJ?

If you need to manually configure IntelliJ IDEA to use Git from WSL, go to the Version Control | Git page of the IDE settings Ctrl+Alt+S , click the Browse icon in the Path to Git executable field and select Git from WSL via the \wsl$ path, for example, \\wsl$\debian\usr\bin\git .

How do I know if IntelliJ is staged changes?

IntelliJ IDEA allows you to review all changes made to the project sources that match the specified filters. For distributed version control systems, such as Git and Mercurial, you can view project history in the Log tab of the Version Control tool window Alt+9 (see Investigate changes in Git repository).


You can use IDEA's directory-based project structure, where the settings are stored in .idea directory instead of .ipr file. It gives more fine-grained control over what is stored in version control. The .iml files will still be around, so it doesn't solve the random changes in them (maybe keep them out of source control?), but sharing things such as code style and inspection profiles is easy, since each of them will be in its own file under the .idea directory.


From official DOC: http://devnet.jetbrains.com/docs/DOC-1186

Depending on the IntelliJ IDEA project format (.ipr file based or .idea directory based), you should put the following IntelliJ IDEA project files under the version control:

.ipr file based format

Share the project .ipr file and and all the .iml module files, don't share the .iws file as it stores user specific settings.

.idea directory based format

Share all the files under .idea directory in the project root except the workspace.xml and tasks.xml files which store user specific settings, also share all the .iml module files.

I put it in my .gitignore:

#Project
workspace.xml
tasks.xml

An official answer is available. Assuming you're using the modern (and now default) .idea folder project format:

  • Add everything...
  • Except .idea/workspace.xml (which is user-specific)
  • Except .idea/tasks.xml (which is user-specific)
  • Except some other files that might contain passwords/keys/etc (see above link for details)

This sample .gitignore file might be a useful reference, though you should still read the above link to understand why these entries appear and decide if you need them.

Personally I also ignore the .idea/find.xml file as this seems to change every time you perform a search operation.


I took workspace.xml out of source control (+ added to .gitignore).


Our team doesn't check in path-specific IntelliJ files. We assume that people know how to use the IDE and set up a project. IntelliJ files go into the 'ignored' change list.

UPDATE:

The answer is easier now that I'm using Maven and its default directory structure.

IntelliJ should be asked to ignore all files in /.svn, /.idea and /target folders. Everything pertaining to an individual's path information is stored in /.idea.

Everything else is fair game to be committed to Subversion or Git.