我知道这里也有类似的问题,但是没有任何建议对我有用,而我正在为此而失去理智!
快速破解:全新编程。从头开始学习Rails的书。
我在mac(osx 10.7.5)上,我已经安装了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的问题完全不同。我抓了整个东西,从第一章开始新鲜,希望我在设置GI时可能会错过一些东西。我之前有一个棘手的问题,Github告诉我存储库不存在。我尝试了很多东西来尝试解决这个问题,我忘记了我曾尝试过的东西。所以我只是想开始干净。我删除了计算机上的“Learn-Rails”目录,并为此重新创建了它。我从我的Github帐户中删除了以前的存储库,现在已经开始了一个新的存储库,但它之前的命名完全相同。这会引起问题吗?
答案 0 :(得分:0)
首先,检查原点是什么。从您的应用根打开.git/config
。应该有这样的东西:
[remote "origin"]
url = git@github.com:tomdunning/gideons.git
fetch = +refs/heads/*:refs/remotes/origin/*
你遇到的下一个问题是合并冲突带来的影响。运行git mergetool
以开始管理每个问题的合并,直到所有问题都得到解决。