Why doesn't expo-cli create a .gitignore file?

Hi,

I am new to expo and I just created a new project using expo init my-new-project per the quickstart instructions on Expo Documentation. I was expecting this command to have created a .gitignore file, because I don’t know the expo file/directory structure and so don’t know what should be gitignored. I know that in general node_modules should be gitignored, but what about this directory .expo that shows up after I connect a device? Thanks for your response!

1 Like

Hey @carlgieringer,

I just tested the expo init command, and it did create .gitignore file.
It doesn’t show up in Finder, but in VS Code I can see it in the list of files on the left.

Let me know if you find it!

Huh! I still can’t find it. Can you see what I am doing wrong?

$ expo init my-new-project
? Choose a template: expo-template-blank
✔ Please enter a few initial configuration values.
  Read more: https://docs.expo.io/versions/latest/workflow/configuration/ · 100% completed
? Yarn v1.10.1 found. Use Yarn to install dependencies? No
Extracting project files...
Customizing project...
Initialized a git repository.
Installing dependencies...
npm WARN lifecycle The node binary used for scripts is /Users/me/.nodenv/shims/node but npm is using /usr/local/Cellar/node/10.11.0/bin/node itself. Use the `--scripts-prepend-node-path` option to include the path for the node binary npm was executed with.

> fsevents@1.2.7 install /Users/me/code/my-new-project/node_modules/fsevents
> node install

node-pre-gyp WARN Using needle for node-pre-gyp https download
[fsevents] Success: "/Users/me/code/my-new-project/node_modules/fsevents/lib/binding/Release/node-v64-darwin-x64/fse.node" is installed via remote
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN expo-google-sign-in@2.0.0 requires a peer of react-native@^0.55.4 but none is installed. You must install peer dependencies yourself.
npm WARN react-native-reanimated@1.0.0-alpha.11 requires a peer of react@16.0.0-alpha.6 but none is installed. You must install peer dependencies yourself.
npm WARN react-native-reanimated@1.0.0-alpha.11 requires a peer of react-native@^0.44.1 but none is installed. You must install peer dependencies yourself.
npm WARN url-loader@1.1.2 requires a peer of webpack@^3.0.0 || ^4.0.0 but none is installed. You must install peer dependencies yourself.

added 927 packages from 442 contributors and audited 19893 packages in 14.639s
found 6 low severity vulnerabilities
  run `npm audit fix` to fix them, or `npm audit` for details

Your project is ready at /Users/me/code/my-new-project

To get started, you can type:

  cd my-new-project
  npm start

$ ls -al my-new-project
total 616
drwxr-xr-x   11 me  staff   352B Mar  9 12:26 .
drwxr-xr-x   13 me  staff   416B Mar  9 12:26 ..
drwxr-xr-x    9 me  staff   288B Mar  9 12:26 .git
-rw-r--r--    1 me  staff     3B Oct 26  1985 .watchmanconfig
-rw-r--r--    1 me  staff   449B Oct 26  1985 App.js
-rw-r--r--    1 me  staff   555B Mar  9 12:26 app.json
drwxr-xr-x    4 me  staff   128B Mar  9 12:26 assets
-rw-r--r--    1 me  staff   107B Oct 26  1985 babel.config.js
drwxr-xr-x  574 me  staff    18K Mar  9 12:26 node_modules
-rw-r--r--    1 me  staff   284K Mar  9 12:26 package-lock.json
-rw-r--r--    1 me  staff   426B Mar  9 12:26 package.json
$ expo --version
2.11.7

I am having the same experience - no ‘.gitignore’ is created

I’m not very familiar with the expo CLI code, but I did find this interesting comment by searching the repo for “gitignore”:

// TODO: Add .expo/* to *gitignore*

Source

Same experience: no .gitignore. VS Code is going crazy trying to index the content of node_modules.
I did the exact same as the OP, except I used Yarn.

I opened an issue here: No .gitignore file provided when using expo init · Issue #433 · expo/expo-cli · GitHub

@charliecruzan could you tell us what should be in the .gitignore file? Currently I have pulled together the following but I have no idea if correct:

.DS_Store
node_modules
.vscode
.idea
package-lock.json
*.log
build/
.eslintcache

I also found this, which looks more comprehensive:

# Expo
.expo
__generated__

# macOS
.DS_Store

# Node
node_modules
npm-debug.log
yarn-error.log

# Emacs
*~

# Vim
.*.swp
.*.swo
.*.swn
.*.swm

# Sublime Text
*.sublime-project
*.sublime-workspace

# Xcode
*.pbxuser
!default.pbxuser
*.xccheckout
*.xcscmblueprint
xcuserdata

# Android Studio
*.iml
.gradle
.idea/libraries
.idea/workspace.xml
.idea/gradle.xml
.idea/misc.xml
.idea/modules.xml
.idea/vcs.xml

# Android
*.apk
/android/**/build
/android/**/local.properties
/android/captures
/android/expoview/libs/ReactAndroid-temp
/android/versioned-react-native/ReactAndroid
ReactAndroid-temp.aar

# Tools
jarjar-rules.txt

# Dynamic Macros
/ios/Exponent/Supporting/EXBuildConstants.plist.bak
/ios/Exponent/Supporting/EXBuildConstants.plist.json
/ios/Exponent/Supporting/EXBuildConstants.plist
/android/expoview/src/main/java/host/exp/exponent/generated/ExponentBuildConstants.java
/android/app/src/androidTest/java/host/exp/exponent/generated/TestBuildConstants.java
.kernel-ngrok-url

# Template files
/android/app/src/main/AndroidManifest.xml
/android/app/google-services.json
/android/expoview/src/main/java/host/exp/exponent/generated/ExponentKeys.java
/android/app/fabric.properties
/ios/Exponent/Generated/EXKeys.h
/ios/ExponentIntegrationTests/EXTestEnvironment.plist
/ios/Podfile
/exponent-view-template/ios/Podfile

# Codemod
.codemod.bookmark

# Fastlane
/*.cer
/fastlane/report.xml
/fastlane/Preview.html
/Deployment
/Preview.html

# CI
/android/logcat.txt

# Shell apps
android-shell-app
shellAppBase-*
shellAppIntermediates
shellAppWorkspaces

# Expo Client builds
/client-builds

# Expo web env
.env.local
.env.development.local
.env.test.local
.env.production.local

Thank you!

@carlgieringer, @robrecord, @sivano

Sorry for the long response time. Turns out that after retesting this (updated Expo CLI to 2.11.9) no .gitignore file is created on my end, either.

Thanks for bringing this up! I’ll be looking into it further.

In the meantime, .gitignore files vary depending on what your project is using. For instance, the most recent one project I’m working on that uses very very few dependencies is:

node_modules/**/*
.expo/*
npm-debug.*
*.jks
*.p12
*.key
*.mobileprovision

So it’s tough for me to say exactly what yours should contain. Sorry about this, hope to have this resolved soon.

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.