7

I am starting off on a React Native project on multiple computers. I'm fairly new to React Native, hence probably this newb question :

What is the minimum of files I need to track with Git in order to be able to sync and work on multiple computers? The whole folder? Can I leave out the platform specific build dirs (ios, android) and have a script recreate those after a git pull origin?

El Dude
  • 5,328
  • 11
  • 54
  • 101
  • 1
    Possible duplicate of [Recommended .gitignore for react-native](https://stackoverflow.com/questions/49099131/recommended-gitignore-for-react-native) – bennygenel Jun 24 '18 at 05:32

1 Answers1

7

You can look at this from a different perspective:

gitignore.io/api/reactnative lists the files/folders you need to not track (ignore)

So simply add the rest (after creating a .gitignore for your react application).

As the OP El Dude mentions in the comments, the react-native eject command can come in handy.
As described in this gist:

If your project has any issues with the native folders, you can rebuild them by deleting both the ios and android directories at the root level of your project and running this command:

$ react-native eject

Running this command will check if the ios and android directories exist and then rebuild whichever one is missing.

More generally, any folder that you can generate does not have to be part of your Git repository.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Thanks. I found there's the `react-native eject` option. So instead of tracking all files in `project/ios` I could be able to re-create all after every `sync` from `origin`? My initial commit contains more than 5000 files with the default `.gitignore`. – El Dude Jun 24 '18 at 05:48
  • @ElDude Good point. I have included and documented your comment in the answer, as well as answered your question. – VonC Jun 24 '18 at 06:39
  • I will try a combination of both. For my project I require `react native maps` which need a little editing in the native build folders. Essentially it will be ignore all native builds but add all files that I had to edit. – El Dude Jun 24 '18 at 18:45