1

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.

deadcoder0904
  • 7,232
  • 12
  • 66
  • 163

2 Answers2

0

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
deadcoder0904
  • 7,232
  • 12
  • 66
  • 163
-1

Your .gitignore file should have only these entries as it will ignore the files recursively inside android and ios directory.

.gitignore

android
ios
kk.
  • 3,747
  • 12
  • 36
  • 67
  • That ignores everything inside `android/` & `ios/` directory. I want to blacklist everything inside `android/` & `ios/` directory & whitelist the above mentioned files. – deadcoder0904 May 20 '19 at 13:51
  • That's not a right way to do it. Add files to ignore list which needs to be ignored and rest of the files can be checked into the repository. – kk. May 20 '19 at 13:55
  • There are tons of files in `ios/` & `android/` folder which I can't one-by-one manually add it. Also, there is no wrong way as there are already solutions: https://stackoverflow.com/a/6011532/6141587 but just not working for me :) – deadcoder0904 May 20 '19 at 13:57