2017-04-27 35 views
-3

我對git有點新。當我嘗試推送文件到遠程回購我收到以下錯誤,我經歷了大量的谷歌搜索,但沒有得到正確的答案。任何人請幫助。我也跟着git推操作錯誤

Note: i have some updated files in remote repo added by others

的步驟,推動

  1. 我在我的本地回購

  2. 我加入,並承諾該文件中的「sample.txt的」,現在我的工作目錄是乾淨的。

  3. 現在我想

    $ git push sample master 
    

    錯誤:

    To github.com:xxxxxx/sample.git ! [rejected] master -> master (fetch first) error: failed to push some refs to '[email protected]:xxxxx/sample.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.`

Note: i have some updated files in remote repo added by others

For reference please check this image

什麼能爲t

branch master -> FETCH_HEAD * [new branch] master -> sample/master fatal: refusing to merge unrelated histories

所以,你需要使用git標誌allow-unrelated-histories拉:他可能的解決方案?,好心用一個例子

+1

你嘗試讀取錯誤消息的信息? – jonrsharpe

+0

是的,我讀了,我試圖抓取,拉動機器人什麼都沒有工作 –

+0

然後顯示你已經嘗試了什麼,發生了什麼,**作爲文本**。拒絕合併無關的歷史 ' – jonrsharpe

回答

2

解釋您按照這裏的評論部分中提到的git pull錯誤。然後做推。

$ git pull sample master --allow-unrelated-histories 
$ git push sample master 

--allow-unrelated-histories:
By default, git merge command refuses to merge histories that do not share a common ancestor. This option can be used to override this safety when merging histories of two projects that started their lives independently. As that is a very rare occasion, no configuration variable to enable this by default exists and will not be added.

More

+0

我試圖拉:> FETCH_HEAD 致命 - –

+0

嘗試'git pull sample master --allow-unrelated-歷史' –

+0

謝謝,這工作正常 –