Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git push rejected

Tags:

git

push

I give up! Whenever I try to push I get a stupid:

! [rejected]        master -> master (non-fast forward) error: failed to push some refs to '[email protected]:companyX/projectX.git' 

Our team has a new git setup. Instead of making private branches I now Forked our main repository (on github) to create my own copy.

At some point what I did was:

$ git fetch upstream master:upstreammaster 

So here is my current setup::

$ git branch master * upstreammaster  $ git remote -v origin  [email protected]:userX/projectX.git upstream    [email protected]:companyX/projectX.git 

where userX is my private repository.

So I go and make some changes to my upstreammaster branch, and the PULL from "upstream master". Everything merges and stuff:

$ git pull upstream master remote: Counting objects: 95, done. remote: Compressing objects: 100% (60/60), done. remote: Total 60 (delta 54), reused 0 (delta 0) Unpacking objects: 100% (60/60), done. From [email protected]:companyX/projectX  * branch            master     -> FETCH_HEAD Merge made by recursive. stuff                      |  165 ++++++++++++-------- stuff                      |   35 ++-- stuff                       |  107 ++++++++++--- stuff                       |  105 ++++++++++--- stuff             |   24 ++-- stuff               |    9 +- stuff                   |   53 +++---- stuff            |   44 +++--- stuff              |   52 +++---- stuff |   32 +---- stuff          |    4 +-  stuff             |  138 ++++++++--------- stuff     |   58 ++++---- stuff    |  115 ++++++++------ stuff          |    5 +- stuff                       |   39 ++--- stuff                        |   28 ++--  17 files changed, 560 insertions(+), 453 deletions(-) 

but then when I try to do:

$ git push upstream master To [email protected]:companyX/projectX.git  ! [rejected]        master -> master (non-fast forward) error: failed to push some refs to '[email protected]:companyX/projectX.git' 

Any help would be greately appreciated! If you need clarification please ask, I will reply!

like image 285
Andriy Drozdyuk Avatar asked Mar 06 '09 20:03

Andriy Drozdyuk


People also ask

How do I fix error failed to push some refs to git?

We can fix the error: failed to push some refs to [remote repo] error in Git using the git pull origin [branch] or git pull --rebase origin [branch] commands. In most cases, the latter fixes the error.

How do I force a git push?

To force a push to only one branch, use a + in front of the refspec to push (e.g git push origin +master to force a push to the master branch).

What does failed to push some refs mean?

This means that someone else pushed a commit to the same branch you're pushing to, but you don't have that commit on your laptop yet. This can happen if it has been awhile since you ran "git pull" on a branch that many people contribute to, such as staging. To fix this issue, run: git pull origin <your-branch>

What is remote rejected?

The error message error: refusing to update checked out branch: refs/heads/master is emitted by the remote repository and it means you're trying to push code to remote non-bare repository that has different code currently checked out in the working directory.


1 Answers

When doing a push, try specifying the refspec for the upstream master:

git push upstream upstreammaster:master 
like image 167
Jarret Hardie Avatar answered Oct 10 '22 20:10

Jarret Hardie