6
To [email protected]:xxx/xxxxx.git ! [rejected] master -> master (non-fast-forward) error: failed to push some refs to '[email protected]:xxx/xxxxx.git' To prevent you from losing history, non-fast-forward updates were rejected Merge the remote changes before pushing again. See the 'Note about fast-forwards' section of 'git push --help' for details. 

I got this error when I tried to push some changes. When I try to fetch from repo i get

From github.com:xxx/xxxxx * branch master -> FETCH_HEAD 

What should I do to solve this ? It's been basically just me on the repo so far, I've had just two pushes from someone else. Do I need to do a proper merge ?

1
  • Did you read the note about fast-forwards in the help, as the error message stated? Commented Oct 15, 2010 at 18:39

1 Answer 1

12

The push is failing because your refs are behind those of the remote repository. The fetch operation only brings down the contents and refs of the remote repository but does not update your refs to the changes. Hence it does nothing to resolve the problem preventing the push. You'll need to either do a pull operation or manual merge with the local version of the remote refs.

Sign up to request clarification or add additional context in comments.

3 Comments

Yep, I solved it just before reading your response. The pull solved it, but I'll mark your answer as accepted.
git pull does a git fetch followed by a git merge
you can also do git rebase origin/master and then git merge origin/master to keep the history linear and not too messy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.