问题
I want to exclude entire android/
& ios/
folder
And I want to include the following files in it:
android/settings.gradle
android/app/build.gradle
android/build.gradle
android/app/src/main/java/com/reactnativegoogleadmob/MainApplication.java
ios/Podfile
ios/ReactNativeGoogleAdmob/AppDelegate.h
ios/ReactNativeGoogleAdmob/AppDelegate.m
So my .gitignore
is:
# Remove following directories
android/*
ios/*
# Add following files
!android/settings.gradle
!android/app/build.gradle
!android/build.gradle
!android/app/src/main/java/com/reactnativegoogleadmob/MainApplication.java
!ios/Podfile
!ios/ReactNativeGoogleAdmob/AppDelegate.h
!ios/ReactNativeGoogleAdmob/AppDelegate.m
But it only includes top level files like:
android/settings.gradle
android/build.gradle
ios/Podfile
I also tried android/**/*
& ios/**/*
but it gives same results as android/*
& ios/*
.
How do I include the rest of the files? I tried other solutions too but hitting a roadblock.
回答1:
I managed to make this thing work thanks to @axiac's answer here.
Read it before reading the solution below as it explains much better than I can explain -
android/*
!android/build.gradle
!android/settings.gradle
!android/app/
android/app/*
!android/app/build.gradle
!android/app/src
android/app/src/*
!android/app/src/main
android/app/src/main/*
!android/app/src/main/java
android/app/src/main/java/*
!android/app/src/main/java/com
android/app/src/main/java/com/*
android/app/src/main/java/com/reactnativegoogleadmob/*
!android/app/src/main/java/com/reactnativegoogleadmob
!android/app/src/main/java/com/reactnativegoogleadmob/MainApplication.java
ios/*
!ios/Podfile
!ios/ReactNativeGoogleAdmob/
ios/ReactNativeGoogleAdmob/*
!ios/ReactNativeGoogleAdmob/AppDelegate.h
!ios/ReactNativeGoogleAdmob/AppDelegate.m
回答2:
Your .gitignore
file should have only these entries as it will ignore the files recursively inside android
and ios
directory.
.gitignore
android
ios
来源:https://stackoverflow.com/questions/56222119/whitelist-nested-files-and-folders-using-gitignore