0

I have a project which looks like this:

docs
rnsrc
src

Inside docs are word docs, pptx, etc. Inside rnsrc is a React Native project and inside src is a client for it (Python.) I would like to have this full directory under Git version control, which I can achieve, but React Native supplies a .gitignore with projects and I cannot get Git to acknowledge it. React Native .gitignore looks like this:

# Xcode
  !**/*.xcodeproj
  !**/*.pbxproj
  !**/*.xcworkspacedata
  !**/*.xcsettings
  !**/*.xcscheme
  *.pbxuser
  !default.pbxuser
  *.mode1v3
  !default.mode1v3
  *.mode2v3
  !default.mode2v3
  *.perspectivev3
  !default.perspectivev3
  xcuserdata
  *.xccheckout
  *.moved-aside
  DerivedData
  *.hmap
  *.ipa
  *.xcuserstate
  project.xcworkspace

  # Gradle
  /build/
  /RNTester/android/app/build/
  /RNTester/android/app/gradle/
  /RNTester/android/app/gradlew
  /RNTester/android/app/gradlew.bat
  /ReactAndroid/build/

  # Buck
  .buckd
  buck-out
  /ReactAndroid/src/main/jni/prebuilt/lib/armeabi-v7a/
  /ReactAndroid/src/main/jni/prebuilt/lib/x86/
  /ReactAndroid/src/main/gen

  # Watchman
  .watchmanconfig

  # Android
  .idea
  .gradle
  local.properties
  *.iml
  /android/

  # Node
  node_modules
  *.log
  .nvm
  /bots/node_modules/
  package-lock.json

  # OS X
  .DS_Store

  # Test generated files
  /ReactAndroid/src/androidTest/assets/AndroidTestBundle.js
  *.js.meta

  /coverage
  /third-party

  # Root dir shouldn't have Xcode project
  /*.xcodeproj

  # ReactCommon subdir shouldn't have Xcode project
  /ReactCommon/**/*.xcodeproj
  RNTester/build

I have tried moving this one level up (into the directory I described at the beginning) and appending:

# Docs
docs

But it doesn't work, "docs" and the entirety of rnsrc is added to the repository. I'm still finding my way around Git and would appreciate some guidance!

Lucas
  • 153
  • 1
  • 11

1 Answers1

0

You can have multiple .gitignore files in a single repo and they would have different scopes, with the one in the root directory being applied to the whole repo, then each one would only affect the files/folders in that path and all of its children.

Edit: If I understand the question, you want files that are already tracked to be removed from your next commit.

If so, look at this answer. Basically, run git rm -r --cached <file> or git rm -r --cached . to remove all files in the .gitignore.

Then add and commit.

Saleh
  • 173
  • 2
  • 12
  • Which is not answer, actually, because, if I understand correctly, author wants those second .gitignore to take effect. – asm0dey Sep 20 '18 at 19:24
  • Aaaah yeah I don't really understand the question, but you're probably right. I'll edit the answer! – Saleh Sep 21 '18 at 21:41