分离后Expo Android应用的VCS管理及提交文件过大问题咨询
Hey there! I’ve been through the same learning curve with Expo ejected React Native apps and team collaboration, so let’s tackle your questions one by one.
1. Should /.expo-source and Android-related files be in VCS?
- /.expo-source: Absolutely not. This is a local cache directory generated by Expo for development purposes—it contains temporary files, cache data, and metadata specific to your local environment. It regenerates every time you start your project, so there’s no reason to track it in Git.
- /android directory: This one’s a mix. You do need to track most core Android project files (like
android/app/src/,android/app/AndroidManifest.xml,android/build.gradle, etc.) because these are part of your app’s native configuration. However, build artifacts and cache directories inside /android should be ignored, including:android/app/build/: Contains compiled APKs, intermediate build files, and other output generated when you build the app locally.android/.gradle/: Gradle’s local cache directory—specific to your machine’s setup.android/local.properties: If this file contains your local Android SDK path (it usually does), ignore it so teammates can use their own SDK paths without conflicts.
2. Is a 10MB single commit reasonable?
Nope, that’s way too big for a code commit—almost certainly because you’re including unnecessary cache/build files I mentioned above. Once you exclude those, the actual code you need to track (native configs + React Native source) should be a fraction of that size. A first commit for an ejected Expo app might be a few MB (due to native project files), but 10MB is a red flag that you’re including non-essential data.
3. Optimization & Fix Steps
Here’s exactly what you can do to clean this up:
- Update your .gitignore file: Add these lines to ensure you’re ignoring the right stuff (use this as a starting point for ejected Expo apps):
# Expo-specific cache .expo-source .expo dist expo-debug.log # Android build artifacts android/app/build/ android/.gradle/ android/captures/ android/local.properties android/gradle.properties # Only ignore if it has local-specific values - Remove already tracked unwanted files: If you’ve already accidentally committed /.expo-source or build files, run these commands to remove them from Git (without deleting them locally):
git rm --cached -r .expo-source git rm --cached -r android/app/build/ git rm --cached android/local.properties - Commit the cleanup: Stage your updated .gitignore and the removal changes, then commit with a message like "Clean up: Ignore Expo cache and Android build artifacts".
- Team collaboration tip: Since you’re working with a teammate, make sure both of you have the same .gitignore setup. For Expo builds, you can either use a shared Expo team account (so you both can build from the same project) or each use your own accounts—just ensure all code changes are synced via Git.
That should get your VCS setup clean and efficient for your team. Let me know if you hit any snags with the Git commands or Expo native configs!
内容的提问来源于stack exchange,提问作者Santiago Montero

