2017-05-05 169 views
0

假设我在GitHub页面上有一个网站。我们打电话给该网站MyFirstSite。现在,我正在尝试在一个新存储库中创建一个新的网站。该网站被称为MyNewSite。添加和滥用职权,MyNewSite文件后,我试图推动更改GH-页面分支,却收到这样的响应:无法推送到github页面

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比较陌生。这可能有一个非常简单的解决方案,但是有人可以为我指出吗?

+1

'git remote -v'显示什么? – captncraig

+1

你肯定试图推动到原来的回购。要么你在错误的目录中,要么你的遥控器全部混在一起 – captncraig

+0

首先尝试git pull然后再次推送 –

回答

0

您可以简单地使用:

git push --force 

,如果你确信你没有遥控器中的任何不同步的文件。作为预防措施,请在使用上述命令之前将repo文件下载或复制到其他位置。

如果您有任何未确认的工作,请在执行git push之前使用git pull并解决任何合并冲突。

0

您的遥控器配置不正确,请尝试删除旧的远程URL副

git remote rm MyFirstSite 

git remote add origin YOUR_REPO_URL

添加新的远程你可以从回购clone or download按钮上得到YOUR_REPO_URL github上。

运行git remote -v,它应该显示类似[email protected]:USERNAME/REPO_NAME.git

现在,你可以把你的变化。