2016-03-08 49 views
-2

我得到下面的錯誤,而我試圖從當地把我的代碼到遠程:Github上的錯誤,而試圖從地方推動代碼遠程

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

是否有人可以幫助我如何解決這一點,因爲,我不知道如何繼續。

僅供參考,我試過清除我的提交歷史幾分鐘回用下面的命令(雖然它得到了在命令提示符成功實施,但我的歷史仍然完好無損我的github頁):

git init 
git remote add origin [email protected]:user/repo 
now commit your current version of code 

git add * 
git commit -am 'message' 
and finally force the update to GitHub: 

git push -f origin master 
+1

你拉了嗎?這就是錯誤信息提示你所做的事情。 – Makoto

+0

閱讀***錯誤:'你可能想在再次推送前先集成遠程更改(例如,'git pull ...')。 – njzk2

回答

0

錯誤你正在得到,是因爲你正在嘗試推送本地更改,這些更改「落後於」遠程上的現有更改。

這裏的解決方案是提交你的本地工作(你已經完成),然後從遠程提取。這將導致合併(並且可能是合併衝突)。如果需要解決合併衝突,請提交這些合併更改。現在,一切都應該準備一個新的「推」 :)

+0

嗨,我已經試過了,當我這樣做時,我得到一個答覆 - >「已經是最新的」。甚至當我再次嘗試推送我的代碼時,我仍然在主要問題 –

+0

中發現上述錯誤您是否在本地使用主分支?你寫的是從主分支中提取數據,如果你真的在另一個分支上,這是沒有意義的。 嘗試「git分支」並在此發佈結果,同時git狀態可能會提供更多信息。 –

+0

Hi Stian,我只有一個分支,即主人。雖然按照您的要求,下面是結果: C:\用戶\ risha_000 \ CS5610Code>的Git分支 *主 C:\用戶\ risha_000 \ CS5610Code>的Git分支 *主 –

0

嘗試git pull origin master

錯誤消息開始說,有對你本地不具備遠程主變化。爲了不消除這些變化,你必須在推動之前拉動。

0

在推送您的更改之前,您應該從原點取得最新的代碼。

git pull origin master 
+0

嗨,我已經試過了,當我這樣做時我收到了一個回覆 - >「至今」。 即使再次嘗試推送我的代碼時,我仍然會在主要問題中發現上述錯誤。 –

0

感謝您的回覆如此之快。

我已經嘗試===>「混帳拉起源大師」,並得到了如下回應:

"C:\Users\risha_000\CS5610Code>git pull origin master 
From ssh://webdevelopment-ranarishabhsingh.rhcloud.com/~/git/webdevelopment 
* branch   master  -> FETCH_HEAD 
Already up-to-date." 

我讀了「混帳推手冊」很好,但坦率地說我不能理解它的大部分。

請建議做些什麼,感謝您的耐心等待,請耐心支持我,因爲我對這些東西相對缺乏經驗,儘管我試圖熟悉它。