'致命:运行后找不到远程引用 refs/heads/gh-pages':git push origin :gh-pages

Sop*_*cai 1 git github-pages

我的 gh-pages 没有正确更新,所以我决定删除旧版本并推送新副本。我采取的一些步骤:

1我在这里找到了如何删除 gh-pages:

https://webapps.stackexchange.com/questions/8512/how-to-remove-github-pages

2然后我运行git push origin :gh-pagesgh-pages就成功删除了。

3我跑的下一步:git push origin gh-pages 我得到了:

'fatal: Couldn't find remote ref refs/heads/gh-pages' 
Run Code Online (Sandbox Code Playgroud)

4尝试在本地创建 gh-pages 然后再次推送。 仅显示 README.md。

5尝试npm rm -rf node_modules/gh-pages/ && npm installhttps://github.com/tschaub/gh-pages/issues/17

但问题仍然存在,同样的致命错误。

额外步骤: 我还配置了我的发布源设置->“GitHub Pages”->'Master',但它似乎不起作用。

https://docs.github.com/en/github/working-with-github-pages/creating-a-github-pages-site#creating-your-site

我做错什么了吗?通过之前运行“npm run deploy”,gh-pages 已成功创建,没有任何戏剧性。所以我不明白出了什么问题。任何想法将不胜感激。

Yuv*_*raj 6

我就是这样解决的

我之前有部署脚本 "deploy": "gh-pages -d build"

我把它改为 "deploy": "gh-pages-clean gh-pages -d build"

然后,我跑了npm run deploy

之后,我将部署脚本更改为之前的状态 "deploy": "gh-pages -d build"

现在,npm run deploy