After deploying a Github page, how do you update it with changes?

Viewed 5169

I've deployed a project as a Github Page using npm run deploy. Now, I have made new changes to my project on my master branch and pushed them to the remote master branch. However, doing so does not seem to update my Github Page. What step(s) am I missing? Do I need to re-run npm run deploy?

3 Answers

After pushing your code to master branch, run npm run deploy. This will make a new commit and push to your gh-pages branch that your GitHub Pages app running on. Then refresh your page. If you don't see any changes, wait a couple minutes and refresh it again.

I faced some issues and found out recently. Yes, you need to deploy it again by npm run deply However, there is "Page not found" issue when you refresh the file you updated.

  • In this case, I deleted the gh-pages branch in Github and deployed again. It worked in my case.

As I'm not sure on which step you messed up I will provide you with steps from the beginning which I follow and everything works perfectly fine.

  1. Create a repository for your app.

run:

npm init react-app appname
  1. Install GitHub Pages package

I use this link: https://www.npmjs.com/package/gh-pages and afterwards: run:

cd appname
npm install gh-pages --save-dev
  1. Modify your repos package.json file

add/change homepage per your names:

"homepage": "http://yourUserName.github.io/appname"

also to the scripts section add:

"predeploy": "npm run build",
"deploy": "gh-pages -d build"
  1. Create a remote GitHub repository and initialize it

run:

git init
git remote add origin git@github.com:yourUserName/appname.git
  1. deploy it to gh-pages.

run:

npm run deploy
  1. Commit and push your changes

run:

git commit -m "commit description"
git push origin master

If something wouldn't work or you would have issues with some step - please leave a comment and I will try to help you

Related