How can I decide to add .idea/jarRepositories.xml in .gitignore

How can I decide to add it or not?

A clear general criteria to decide if you should ignore a file is:

Can you clone the repository without that file and still have a valid project (one you can compile and execute)

For example, if that file is automatically regenerated, or re-created with custom local paths (which would not make sense for a different developer on a different PC), then that file can be ignored.

So try it out, especially considering you can "disable or enable Gradle / Maven auto-import for an IntelliJ IDEA project".


The file .idea/jarRepositories.xml should be added to .gitignore. It is auto-generated and has only redundant information about remote jar repositories.

Our Android projects define those repositories in the project-level build.gradle such as:

allprojects {
    repositories {
        google()
        jcenter()
    }
}
  • https://developer.android.com/studio/build#top-level
  • https://developer.android.com/studio/build/dependencies.html#remote-repositories
  • https://docs.gradle.org/current/userguide/dependency_management.html#declaring-repositories

The second reference wrote the following introduction at the top of its webpage:

Add build dependencies

The Gradle build system in Android Studio makes it easy to include external binaries or other library modules to your build as dependencies. ... This page describes how to use dependencies with your Android project, ... but remember that your Android project must use only the dependency configurations defined on this page. [emphasis added]

Also, Add Library Dependencies dialog in Android Studio 4.0.1 has an instruction like this:

Step 1.

Use the form below to find the library to add. This form uses the repositories specified in the project's build files (Google, JCenter, Android Repository, Google Repository)

You can find it with the following steps:

  1. Select File > Project Structure... in the menu of Android Studio.
  2. Select Dependencies in the left-side menu of Project Structure dialog.
  3. Select app in the Modules column.
  4. Select + in the Declared Dependencies column.
  5. Select 1 Library Dependency in the popup menu.