Home > Blockchain >  How to push entire React folder to github?
How to push entire React folder to github?

Time:11-06

I am working on a project that uses both React and Springboot apps, so I have individual folders for each of those and am trying to get them both into my github repo. I was easily able to drag and drop the springboot folder, but my react one does not upload at all when I drag it into the upload box. Is there an easy terminal command in vs code (the editor I'm using) to add the entire folder?

CodePudding user response:

Since you want to add your 2 different projects in 1 repository, you can firstly put both of your project folder inside 1 main folder, example:

MyFolder:
  - MyReactProject
  - MySpringbootProject

here MyFolder is your main folder, which has both of your projects, react and springboot. then finally make a file inside MyFolder with name .gitignore, and put this line inside that file:

**/node_modules

what this file will do, is when you will push your code to github, it will ignore all the files and folders which are listed inside .gitignore file.


You Don't Need node_modules folder

when uploading your code somewhere online, you don't need to upload the node_modules folder, because this folder contains all the dependencies your project need, but when uploading your code online people can download those dependencies by calling the command npm install which will read all the modules needed from your package.json file, and download it on your machine.


To upload your code online you first have to authorize yourself on your local git program, to authorize yourself for github you can read this Article.

After authorizing yourself, firstly make a new empty github repository, by going to github or just by clicking this Link, after making a github repository open Terminal/Command Prompt in your Folder where both of your projects were, in this context my both projects were in MyFolder.

After opening Terminal/Command Prompt enter this commands:

git init
git branch -M main
git add .
git commit "Added all the files"

After running these commands, finally run these 2 final commands:

git remote add origin https://github.com/username/repository-name.git

here, replace username with your github username, and replace repository-name with the name of your repository you specified while make a new repository.

and finally run this command

git push -u origin main

and your code should be pushed on github.


If you don't want to use git commands you can also use, Github Desktop, but it is recommended you first learn basics of git and then use github desktop

  • Related