Reputation: 401
I know there are similar questions to this, but nothing that has been suggested is working for me, and I'm losing my mind with this!
Quick rundown: Completely new to programming. Started from scratch on learning Rails with a book.
I'm on a mac(osx 10.7.5),I've installed Ruby, Rails, and Git (and the needed command line tools), but git/github is definitely giving me problems.
I followed what was suggested here: Github "Updates were rejected because the remote contains work that you do not have"
So first I did:
git remote add origin https:/github.com/MY_USER/learn-rails.git
and I get:
fatal: remote origin already exists.
I then move on to:
git push -u origin master
and I keep getting the following error:
![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.
I go ahead and try:
git pull origin master
which gives me this:
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.
Even more background info: This is my second go around with this test/learning project due to having completely different problems pushing to Github previously. I scratched the whole thing and started fresh from chapter one, hoping that I might of just missed something when I was setting up GIt. I was previously have a ver stubborn problem with Github telling me the repository doesn't exist. I tried so many things to try and fix that problem, that I lost track of what I had even tried. So I just wanted to start clean. I deleted the "Learn-Rails" directory on my computer, and recreated it for this go around. I deleted the previous repository from my Github account, and now have started a new one, but it was named the same exact thing before. Would that cause an issue?
Upvotes: 2
Views: 3078
Reputation: 4877
Firstly, check what the origin is. Open .git/config
from your app root. should have something like this in there:
[remote "origin"]
url = [email protected]:tomdunning/gideons.git
fetch = +refs/heads/*:refs/remotes/origin/*
The next issue you had was the pull brought in a merge conflict. Run git mergetool
to start managing the merge for each issue until all are resolved.
Upvotes: 1