Sitemap

Deploying new React application on Github

4 min readNov 19, 2019

--

First of all — create your react app.

Then sign in to Github and add a new project.

I named my project: ApprovalCard.

Open your command line.

Navigate to your React project.

Install gh-pages. Type:
npm install gh-pages — save-dev

#wait couple minutes…

When installation of gh-pages is over, on next line type:
git init

Then add in your initialized empty Git repository all files in your project by typing:
git add — — all

Next, on command line type:
git commit -m ‘’some text about the commitment by your choice’’

#master (root-commit) …. first commitment #(nmb) files changed, (nmb) insertions #create mode ...

Get Stefan Vasic’s stories in your inbox

Join Medium for free to get updates from this writer.

On command line type:
git remote add origin https://github.com/(yourusername)/(project name.git) — you can find that address on Github project page when creating your new repository without Readme link.

Press enter or click to view image in full size
Press enter or click to view image in full size

Type:
git push origin master

Now, open your project folder on the tool that you use for typing code (Visual Studio, Atom, etc) and find package.json file:
below ‘’private’’: true, type:
‘’homepage’’: ‘’your user name(dot)github.io(slash)projectname(slash)’’
In my case, for the project that I was uploading: ‘’https://stefanvasic123.github.io/approvalcard/'', (add that dash on the end of the link) (don't forget a comma, in the end, its object after all);
In ‘’scripts’’ above ‘’build’’ element add two more lines:
‘’predeploy’’: ‘’npm run build’’,
‘’deploy’’: ‘’gh-pages -d build’’,
…save (ctrl + s)

Get back to your command line and type:
npm run deploy

On your GitHub project page, in branch field change master branches to gh-pages.

Then, go to settings (on the right corner).
On the left side of the settings panel find branches and set gh-pages as default (choose, hit update, and mark I understand..)

Press enter or click to view image in full size

Go back to settings — options, and on end of the page you see section GitHub Pages, and inside link of your published deployed project

Press enter or click to view image in full size

Go back to command line, type:
npm run deploy

Problems:

If nothing doesn’t show on your published link search for alerts on the main page of the project and run deploy again or see look for the problems with remote origin:

If you see this:
fatal: remote origin already exist
Then remove origin and add a new one by typing:
git remote -v
git remote rm origin
git remote add origin (…address on Github project page when creating your new repository)

I hope this article hepled you.

--

--

Stefan Vasic
Stefan Vasic

Written by Stefan Vasic

0 followers

writing, developing web apps, belonging to the world of entrepreneurship, creation and creativity