2017-05-05 166 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

現在,你可以把你的變化。