首页 > 解决方案 > 如何在 github pages 中的 react 网页中进行更改?

问题描述

main我已经在分支中成功部署了我的反应网页。有我的主要源文件,看看Main branch。部署后,分支gh-pages包含所有必要的文件,其中包含静态文件夹和所有...看看这里gh-pages branch

但是每当我在main分支中更改时,它都不会反映网页。有什么办法可以推动我所有的变化?

gh-pages恐怕我无法将更改推送到分支,因为它具有完全不同的文件。

我该如何进行这些更改?

我遵循了这些 git 命令,但它没有用

$ git add .
$ git status // to see what changes are going to be commited
$ git commit -m 'Some descriptive commit message'
$ git push origin master

$ git checkout gh-pages // go to the gh-pages branch
$ git rebase master // bring gh-pages up to date with master
$ git push origin gh-pages // commit the changes
$ git checkout master // return to the master branch

这里引用

提前致谢...

标签: reactjsgitbranch

解决方案


确保你的 package.json 文件中有这些脚本,然后你就可以运行npm run deploy

"scripts": {
//...
"predeploy": "npm run build",
"deploy": "gh-pages -d build"
}

推荐阅读