Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have created a new branch and I'm working on it with others dev but for reasons when I want to push my new commits I always have to git merge origin/mynewbranch Otherwise I'm getting some errors:

 ! [rejected]        mynewbranch -> mynewbranch (non-fast-forward)
error: failed to push some refs to ''
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.

You asked me to pull without telling me which branch you
want to merge with, and 'branch.mynewbranch.merge' in
your configuration file does not tell me, either. Please
specify which branch you want to use on the command line and
try again (e.g. 'git pull <repository> <refspec>').
See git-pull(1) for details.

If you often merge with the same branch, you may want to
use something like the following in your configuration file:

    [branch "mynewbranch"]
    remote = <nickname>
    merge = <remote-ref>

    [remote "<nickname>"]
    url = <url>
    fetch = <refspec>

See git-config(1) for details.

Why is it not automatic?


share|improve this question
Did you read the documentation you were pointed to? If yes, could you say what exactly you need clarification on? – Benjamin Bannier Jan 11 '11 at 18:12
Well I was just wondering why it's not merging automaticaly anymore, just to know what I did wrong. – mnml Jan 11 '11 at 18:26
up vote 2 down vote accepted

You did nothing wrong per se, but if the remote branch is updated (push to) from other developers, then your own contribution (push) won't be accepted directly.

git push (section "Note about fast-forwards") mentions:

You can perform "git pull", resolve potential conflicts, and "git push" the result. A "git pull" will create a merge commit C between commits A and B.

Alternatively, you can rebase your change between X and B on top of A, with "git pull --rebase", and push the result back. The rebase will create a new commit D that builds the change between X and B on top of A.

See also "I am not able to push on git?" for more.

share|improve this answer
With a rebase my branch will be removed once it's done? Or will it just updated with the changes of the master branch? – mnml Jan 12 '11 at 9:14
@mnml: a rebase means your branch get replayed on top of what has been fetch: it doesn't remove your branch. – VonC Jan 12 '11 at 9:29
Is it possible to rebase the master on top of the new branch? – mnml Jan 12 '11 at 11:51
@mnml: since master is often push, this isn't advisable. One usually rebases one's branch on top of master (git checkout mybranch; git rebase master) – VonC Jan 12 '11 at 12:09

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.