【问题标题】:How Can I Update My Github Pages Website?如何更新我的 Github Pages 网站?
【发布时间】:2020-06-17 01:33:15
【问题描述】:

我已将我的 github 网站部署到 a.github.io。现在,我在本地进行了一些更改并想推送更改,但我无法这样做。这是我的 repo 设置在 Github Pages 部分中所说的:

在我的仓库中,我可以看到提交正在显示。但是,该网站仍然没有更新。如果我在本地运行它,我会看到更改,但不会在实际网站上看到。请注意,它托管的网站的原始帐户也与我进行提交的帐户不同。

当我通过终端访问本地仓库并运行时

git config --list

我收到的不是我的用户名和电子邮件,而是我的两个不同帐户的两封不同的电子邮件。第一个 user.name 基本上是我托管网站的电子邮件地址。 user.email 是我用来推送更改的电子邮件。

user.name=ab@hotmail.com user.email=ab@gmail.com

这就是我尝试更新网站的方式(上次推送工作但它甚至不工作):

git add *
git commit -m "added new picture"

结果:

On branch master
Your branch is ahead of 'origin/master' by 1 commit.
  (use "git push" to publish your local commits)

Changes not staged for commit:
    deleted:    favicon.ico
    deleted:    logo192.png
    deleted:    logo512.png
    deleted:    z<

no changes added to commit
git push

结果:

 ! [rejected]          master -> master (fetch first)
error: failed to push some refs to 'https://github.com/aa
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

然后npm run deploy

【问题讨论】:

标签: git ubuntu github github-pages git-commit


【解决方案1】:

尝试先拉再推。

git pull

编辑:

如果拉取后出现合并冲突,您需要在再次推送之前解决它们。

警告:不推荐使用此选项,但如果您是唯一工作的开发人员,您可以使用强制提交。这将删除过去的提交,请谨慎使用。它可以更改同一项目中其他人的历史记录。

git push -f origin master

【讨论】:

  • 我上次尝试使用 pull 但是我所有的原始文件都将被更改为静态和其他通常在 .github.io 网站存储库中可见的文件夹。
  • 我使用了这个推送命令。推送成功但网站仍未更新
  • 我建议稍等。通常,当我推送到 github 页面时,大约需要 10 分钟才能看到更改。另外不要忘记清除浏览器缓存。
  • 它仍然没有改变。我什至从另一个浏览器检查。恐怕问题可能出在其他地方
  • 您推送的更改在 github 存储库中是否可见?您推送的用户名是否与您上次所说的相同?您也可以尝试再次停用并激活 GitHub Pages。您也可以查看这篇文章 - link
猜你喜欢
  • 2016-08-23
  • 1970-01-01
  • 2021-01-06
  • 2021-12-11
  • 2020-09-08
  • 1970-01-01
  • 2018-11-08
  • 2021-07-02
相关资源
最近更新 更多