-4

Possible Duplicate:
Git non-fast-forward rejected

How to fix this error? It didn't happen previously

Community
  • 1
  • 1

2 Answers2

0

git pull origin master will grab the remote's changes and merge them with yours.

git rebase origin/master will replay you local changes not in the remote on top of any changes on remote. After you do a git fetch origin, pulling automatically does the fetch step. Learn about rebasing in git.

What happened is that someone else (or you on a different machine) also pushed to the origin repo with a different set of commits. Until you have those commits, it won't let you push unless you include --force. Don't do that unless you have to by the way.

Travis
  • 10,444
  • 2
  • 28
  • 48
  • A better approach may simply be `git pull origin master` -- there are times when rebasing may cause more problems than pulling. Hate to downvote, but this may lead the user to a bad result. Edit to offer the option to also pull and I'll remove the downvote. – Kevin Bedell Jul 02 '12 at 22:42
  • Since it will be non-ff merge, you can have just as many issues that way. It really just depend on where the missing commits exist in the tree. Regardless, pulls are less typing I guess. – Travis Jul 03 '12 at 14:15
  • I was mainly thinking it best to make sure they know it's an option -- and that it may be easier depending on the state of the code. Thanks for responding. – Kevin Bedell Jul 03 '12 at 14:17
  • Won't argue with letting people make informed choices. – Travis Jul 03 '12 at 14:18
0

Well the message tells you what to do: git pull, (fetches and merges changes), then git push again.

jasir
  • 1,461
  • 11
  • 28