React && Github
I will discuss the appropriate way to create a react application that points to a Github repo. First, I will set up a react application locally. Secondly, set up a Github repo and lastly point my local react application to the newly created Github repo to push my changes to.
*Prerequisites you need to have updated versions of Node.js, npm, create-react-app, Github Account, Git setup
React
- Create a folder with the project name
- my-app
Inside my-app open up the terminal, I use vscode Integrated Terminal by right clicking in my-app
-
In the terminal run
npx create-react-app .
- Don't forget the dot(.)
- This builds the react template and the dot assigns top level project folder named "my-app" You should see your file structure on the left after CRA is executed
Run
npm start
to confirm React is working in the browser below.
Close the browser at this point and leave vscode open*
We now have a working React app with it's own local git only. All the git commands like add
and commit
would remain local and never reach Github. In the next step we will set up a Github repo.
Github
- Go to your Github account and create repo by clicking on "repositories" and then "new"
- Enter the name of your repo, I'll call it test-app it can be different from the project folder named "my-app".
- radio button public
- **Crucial -- Do not add README, .gitignore or license
- click on Create repository green button Once the screen appears you are ready to go back to the vscode terminal
- Now we are ready to use our newly created github repo with react in the same vscode terminal we created the CRA and run this command
git remote add origin https://github.com/username/test-app.git
- In my case it was
git remote add origin https://github.com/GregPetropoulos/test-app.git
- In my case it was
- This command is to check if we are pointing the correct repo
git remote -v
-
- we get a notification that set upstream flag is needed
Links 🔗
❤️❤️❤️
Social
Twitter
Linkedin
Portfolio
Github
🤘
Happy Coding!
Top comments (0)