-1

I'm working on learning rails and I'm new to Git. I downloaded the zip file of my last commit from Git yesterday because I made a mess of my project and wanted to backtrack (now I'm sensing that was not the way to handle it). Any way - how do I merge my updated project with the original? This is what Git is telling me.

 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'git@github.com:xxxxxx/xxxxx.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.
  • Do a `git pull` before you `git push`. – vee Jun 21 '14 at 14:58
  • do `git pull` to merge the updates. – newbie Jun 21 '14 at 14:58
  • @vee I did a git pull and this is what I got: There is no tracking information for the current branch. Please specify which branch you want to merge with. See git-pull(1) for details – latazzajones Jun 21 '14 at 15:04
  • You don't have upstream specified, you could either set it using `git branch --set-upstream-to=origin/master master` before `git pull` or specify remote branch in git pull with `git pull origin master`. – vee Jun 21 '14 at 15:15
  • Duplicate of [Issue pushing new code in Github](http://stackoverflow.com/questions/20939648/issue-pushing-new-code-in-github) –  Jun 22 '14 at 02:55

2 Answers2

2

Do git fetch and then git rebase. In this case it won't pollute history with merges. If you have uncommitted changes you can save it aside with git stash. When you are done with fetch & rebase, you can return it back with git stash pop.

Alex P
  • 1,721
  • 1
  • 17
  • 18
  • Instead of doing a rebase, the original poster could just `git merge` after the fetch too, though of course that may or may not result in a different commit history graph. –  Jun 22 '14 at 02:58
0

The remote repository contains already some changes (probably made via the web ui or yesterday ? ) do a 'git pull' as proposed. If you want to lose your local changes, you can delete your local repository and do 'git clone ...'

mestachs
  • 1,889
  • 15
  • 17