我知道有類似的問題,但沒有任何建議爲我工作,我正在失去我的想法!「更新被拒絕」試圖推送到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帳戶中刪除了以前的存儲庫,現在已經開始了一個新的存儲庫,但之前它的命名是一樣的。會導致問題嗎?
首先做'git commit -m'消息''或'git commit -A'消息'' – scaryguy
'git push origin master -f' – itsnikolay
謝謝@scaryguy我也這麼做過。 –