Git failed to push some refs – the multiple branch variant

February 25, 2010

By now I knew enough about Git to easily deal with the “error: failed to push some refs” error.

Just pull first, fix any merge problems, and then push.

But this morning I still got the error after doing a pull, then a push to the Bixo project on GitHub.
It turns out I need to read the git output more closely. The error message said:

! [rejected]        master -> master (non-fast forward)
error: failed to push some refs to 'git@github.com:bixo/bixo.git'

But I’m working in a branch (called ‘fetch-flow’). And the “git push” command will try to push all of the branches. But “git pull” only pulls the current branch.

So I had to “git checkout master” to switch to the master branch, then “git pull” to bring that up to date, then “git checkout fetch-flow” to switch back to my branch.

And now my git push works fine. Note that the push did work, in that my ‘fetch-flow’ branch was pushed – it’s just that the auto-push to master failed, and that made me think my entire push had failed.

Advertisements