2014-01-25 54 views
1

我知道有類似的問題,但沒有任何建議爲我工作,我正在失去我的想法!「更新被拒絕」試圖推送到Github

快速簡介:完全是編程新手。從頭開始學習Rails的一本書。我已經安裝了Ruby,Rails和Git(以及所需的命令行工具),但git/github肯定會給我帶來問題。
我也跟着發生了什麼這裏建議:Github "Updates were rejected because the remote contains work that you do not have"

所以首先我所做的:

git remote add origin https:/github.com/MY_USER/learn-rails.git 

,我也得到:

fatal: remote origin already exists. 

我然後移動到:

git push -u origin master 

我不斷收到以下錯誤:

![rejected]master -> master (fetch first) 
error: failed to push some refs to 'https://github.com/MY_USER_NAME/learn-rails.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. 

我繼續前進,並嘗試:

git pull origin master 

,給了我這樣的:

From https://github.com/MY_USER/learn-rails 
* branch   master  -> FETCH_HEAD 
Auto-merging config/initializers/secret_token.rb 
CONFLICT (add/add): Merge conflict in config/initializers/secret_token.rb 
Auto-merging config/environments/development.rb 
CONFLICT (add/add): Merge conflict in config/environments/development.rb 
Auto-merging Gemfile.lock 
CONFLICT (add/add): Merge conflict in Gemfile.lock 
Auto-merging Gemfile 
CONFLICT (add/add): Merge conflict in Gemfile 
Auto-merging .gitignore 
CONFLICT (add/add): Merge conflict in .gitignore 
Automatic merge failed; fix conflicts and then commit the result.   

甚至更​​多的背景信息:這是我第二次與這個測試四處/學習項目因到之前向Github推出完全不同的問題。我抓住了整個事情,從第一章開始重新開始,希望當我建立GIt時,我可能錯過了一些東西。我以前有一個固執的問題與Github告訴我存儲庫不存在。我嘗試了很多事情來嘗試解決這個問題,以至於我失去了曾經嘗試過的東西。所以我只是想開始乾淨。我在計算機上刪除了「Learn-Rails」目錄,併爲此重新創建它。我從我的Github帳戶中刪除了以前的存儲庫,現在已經開始了一個新的存儲庫,但之前它的命名是一樣的。會導致問題嗎?

+0

首先做'git commit -m'消息''或'git commit -A'消息'' – scaryguy

+0

'git push origin master -f' – itsnikolay

+0

謝謝@scaryguy我也這麼做過。 –

回答

0

首先,檢查來源是什麼。從您的應用根打開.git/config。應該有這樣的事情在那裏:

[remote "origin"] 
    url = [email protected]:tomdunning/gideons.git 
    fetch = +refs/heads/*:refs/remotes/origin/* 

你的下一個問題是拉入合併衝突。運行git mergetool開始管理每個問題的合併,直到全部解決。

+0

謝謝你的回覆!我這樣做,在我的文件中,伴隨着這一點,上面:[核心] \t repositoryformatversion = 0 \t FILEMODE =真 \t裸=假 \t logallrefupdates =真 \t忽略大小寫=真 \t precomposeunicode =假 –

+0

當我運行mergetool,我被告知它沒有配置,然後我得到這個:'git mergetool'現在將嘗試使用以下工具之一: opendiff kdiff3 tkdiff xxdiff meld tortoisemerge gvimdiff diffuse ecmerge p4merge araxis bc3 codecompare emerge vimdiff 合併: .gitignore Gemfile Gemfile.lock的 配置/環境/ development.rb 配置/初始化/ secret_token.rb –

+0

當我運行合併工具的幫助下,我得到:「混帳合併工具--tool- 」可以設置爲下列之一: \t \t出現 \t \t了opendiff \t \t Vimdiff可以 \t \t vimdiff2 下面的工具是有效的,但目前無法使用: \t \t araxis \t \t BC3 \t \t codecompare \t \t deltawalker \t \t diffmerge \t \t漫 \t \t ecmerge \t \t gvimdiff \t \t gvimdiff2 \t \t kdiff3 \t \t MELD \t \t p4merge \t \t tkdiff \t \t的TortoiseMerge \t \t xxdiff –

相關問題