无法推送到github页面
假设我在GitHub页面上有一个网站。让我们把那个网站叫做MyFirstSite。现在,我正在尝试在一个新的存储库中创建一个新网站。那个网站叫做MyNewSite。添加并提交MyNewSite文件后,我试图将更改推送到gh pages分支,但收到以下响应:无法推送到github页面,git,github,github-pages,Git,Github,Github Pages,假设我在GitHub页面上有一个网站。让我们把那个网站叫做MyFirstSite。现在,我正在尝试在一个新的存储库中创建一个新网站。那个网站叫做MyNewSite。添加并提交MyNewSite文件后,我试图将更改推送到gh pages分支,但收到以下响应: To http://github.com/Jaklabs/MyFirstSite ! [rejected] gh-pages -> gh-pages (fetch first) error: failed to push
To http://github.com/Jaklabs/MyFirstSite
! [rejected] gh-pages -> gh-pages (fetch first)
error: failed to push some refs to 'http://github.com/Jaklabs/MyFirstSite'
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.
这就好像它试图将文件推送到我的另一个存储库,而不是我试图使用的存储库。我是Git的新手。对此可能有一个非常简单的解决方案,但有人能为我指出吗?您可以简单地使用:
git push --force
如果您确定遥控器中没有任何未同步的文件。作为预防措施,在使用上述命令之前,请将repo的文件下载或克隆到另一个位置
如果您有任何未同步的工作,请在执行
git push
之前使用git pull
,并解决任何合并冲突。您的远程未正确配置,请尝试通过-
git remote rm MyFirstSite
并添加一个新的遥控器
git-remote-add-origin-YOUR\u-REPO\u-URL
您可以从github上的REPO克隆或下载按钮获取您的\u REPO\u URL
运行git remote-v
,它应该显示类似git@github.com:USERNAME/REPO_NAME.git
现在,您可以推送您的更改。git remote-v
显示了什么?您肯定在尝试推送原始回购。您可能是在错误的目录中,或者您的远程设备都混在一起了。请先尝试git-pull,然后再推“git-remote-v”outputsMyFirstSitehttps://github.com/L.C.J/MyFirstSite (获取)
和MyFirstSitehttps://github.com/L.C.J/MyFirstSite (按)
。是的,遥控器肯定出了问题,但我该怎么修理呢?