question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Default .gitignore generated by react-native init has overly aggressive excludes for Android/IntelliJ project files

See original GitHub issue

Description

Generating a new project with the npx react-native init command creates a .gitignore file which excludes the following file types under the Android/IntelliJ heading

# Android/IntelliJ
#
build/
.idea
.gradle
local.properties
*.iml

Excluding the entire .idea directory is incorrect. In some cases, excluding all .iml files is incorrect. See https://intellij-support.jetbrains.com/hc/en-us/articles/206544839-How-to-manage-projects-under-Version-Control-Systems

React Native version:

$ npx react-native info
info Fetching system and libraries information...
System:
    OS: macOS 11.1
    CPU: (8) x64 Intel(R) Core(TM) i7-7920HQ CPU @ 3.10GHz
    Memory: 113.26 MB / 16.00 GB
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 14.15.3 - ~/n/bin/node
    Yarn: Not Found
    npm: 6.14.11 - ~/n/bin/npm
    Watchman: Not Found
  Managers:
    CocoaPods: 1.9.1 - /Users/chris/.rvm/rubies/ruby-2.7.0/bin/pod
  SDKs:
    iOS SDK:
      Platforms: iOS 14.3, DriverKit 20.2, macOS 11.1, tvOS 14.3, watchOS 7.2
    Android SDK:
      API Levels: 28, 29, 30
      Build Tools: 28.0.3, 29.0.3, 30.0.3
      System Images: android-28 | Google Play Intel x86 Atom, android-29 | Google Play Intel x86 Atom, android-30 | Google Play Intel x86 Atom
      Android NDK: Not Found
  IDEs:
    Android Studio: 4.1 AI-201.8743.12.41.6953283
    Xcode: 12.3/12C33 - /usr/bin/xcodebuild
  Languages:
    Java: 1.8.0_275 - /usr/bin/javac
    Python: 2.7.16 - /usr/bin/python
  npmPackages:
    @react-native-community/cli: Not Found
    react: 16.13.1 => 16.13.1 
    react-native: 0.63.4 => 0.63.4 
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

Steps To Reproduce

Provide a detailed list of steps that reproduce the issue.

  1. Generate a new project with npx react-native init, for example npx react-native init ReactNativeHello
  2. Look at the generated .gitnore file

Expected Results

Should only exclude files as recommended by JetBrains at: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839-How-to-manage-projects-under-Version-Control-Systems

For example, JetBrains says:

Here is what you need to share:

  • All the files under the .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
  • All the .iml module files that can be located in different module directories (applies to IntelliJ IDEA)

The current generated .gitnore excludes the entire .idea directory and .iml files, both of which are incorrect according to the above.

Also, for anyone choosing the legacy IntelliJ project format (.ipr/.iml/.iws files), then excluding .iml is incorrect:

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

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
safaiyehcommented, Jan 16, 2021

@chrisbartley This is a very opinionated issue, it depends on the community to decided the best route. I would propose to start a thread in discussions & proposals https://github.com/react-native-community/discussions-and-proposals

Closing for now until a decision is made in the proposals.

0reactions
cortinicocommented, Nov 26, 2021

but write the .gitignore accordingly. Don’t just blindly exclude .iml.

Don’t you mind sending a PR to update it?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Recommended .gitignore for react-native - Stack Overflow
This is what I am using. The content should be save in the .gitignore after ios and android envirment like (signature, config file)...
Read more >
Default .gitignore creation when running git init? - Reddit
Wondering if there's any way to have git drop a default .gitignore into a project directory when we run git init. Guessing we'll...
Read more >
What are the differences between .gitignore and .gitkeep?
gitignore and add a list of files or folders that we don't want to add to the Git repository. It will ignore the...
Read more >
How To Create a .gitignore for a Clean React Repository
Having a well structured .gitignore file is an important part of maintaining productivity so you are able to focus on your changes without ......
Read more >
IntelliJ IDEA, Git, Github, and .gitignore - YouTube
After freshly installing IntelliJ IDEA, share a project to GitHub. To do this, we need git.exe installed on our computer, a project to ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found