首页 > 解决方案 > 无法提交对 Github 页面的更改

问题描述

我已将我的投资组合部署到我在 a.github.io 上的帐户。

我做了一些更改,但它们不会在网站上上线。事实上,即使我在 Visual Studio 上进行了更改,提交部分也没有显示任何提交。

如果我提交更改,我会得到

On branch master
Your branch is up to date with 'origin/master'.

Changes not staged for commit:
modified: node_modules/gh-pages/.cache/github.com!a!a.github.io.git (new commits)

no changes added to commit 

即使我正在做出改变。

所以我的更改不会生效。

编辑:

现在,提交工作了,但是当我推送更改时我得到了这个:

 ! [rejected]          master -> master (fetch first)
error: failed to push some refs to 'https://github.com/a/a.github.io.git'
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.

标签: gitvisual-studiogithubterminalgithub-pages

解决方案


如果您进行了任何更改,git status 应该会显示它们,并且您应该在某个时候完成 git add + git commit。

如果推送仍然失败,请检查您的 git status 是否显示分支。


如果不是,您处于分离 HEAD模式,这可以解释为什么不推送提交。

git switch -c tmp
git switch -C master tmp

然后,这会将 master 重置为当前(分离的 HEAD)提交。


如果你得到:

new file...

至少你需要做一个git add+ git commit,但再次检查当前分支。


推荐阅读