How to use Git with React Native
(for Mac users)
- While in your root directory, use terminal to create your react native project.
$ react-native init gittest
2. Change your directory to your new project.
$ cd gittest
3. Initialize your project for git.
$ git init
4. Add all the files created by step #1.
$ git add .
5. Commit the files and add a message.
$ git commit -m “initial commit”
6. Now go to your github dashboard and create a new project.
7. Enter a name for your repository and click the “Create repository” button.
8. Copy the URL to the clipboard.
9. Go back to your terminal and set the origin by pasting the url from the clipboard.
$ git remote add origin {paste url from clipboard}
10. Push the files from your local machine to your github repository.
$ git push -u origin master
Done. Your github repository is now setup. Use your git commands to commit and push code to your github repository after making code modifications on your local machine.
$ git commit -m “{message here}”
$ git push -u origin master
Hope this helps get you going with git and using your github repository for your react native projects.