Revision control on scala project, file.iml

I’m creating a new project using IntelliJ, and I want to be able to edit this project from two different geographical locations (home and work), sharing using GitLab. Which files should I commit to the git repository?

For example, should I commit the top level .iml file in the project directory whose content is the following? Presumably I will import an sbt project when I clone the repository from the other computer, and all the IntelliJ specific files will get recreated automatically. Right?

<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
  <component name="NewModuleRootManager" inherit-compiler-output="true">
    <exclude-output />
    <content url="file://$MODULE_DIR$">
      <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
    </content>
    <orderEntry type="inheritedJdk" />
    <orderEntry type="sourceFolder" forTests="false" />
    <orderEntry type="library" name="scala-sdk-2.11.7" level="application" />
  </component>
</module>

If you created an SBT project, you typically don’t want to commit the Intellij-specific files to the repository (as you said, you can always import into Intellij based on the SBT build definition).

You can probably just add the .idea/ directory to your gitignore; but if you have doubts about other files, Github’s reference gitignore files can be quite helpful. For Intellij, see this: https://github.com/github/gitignore/blob/master/Global/JetBrains.gitignore.

Note that if you created an Intellij-only project (not an SBT project), Jetbrains has a helpfull support article about which files should be shared: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839