tags:

views:

902

answers:

4

I have a master and a beta branch. There is a situation where push is rejected:

edit2: I am on branch master.

$ git push
Counting objects: 9, done.
Compressing objects: 100% (6/6), done.
Writing objects: 100% (6/6), 669.81 KiB, done.
Total 6 (delta 2), reused 0 (delta 0)
To [email protected]:foobar/codedemo.git
   a5fc71d..64430c1  master -> master
 ! [rejected]        beta -> beta (non-fast forward)
error: failed to push some refs to '[email protected]:foobar/codedemo.git'

Normally I would checkout beta, then pull beta and this wold probably solve it.

But because this is a production website I cannot checkout beta here. Is there a way I can pull beta without checking it out?

As this is a production site I am somehow stuck.

Edit: The code is also checked out on another location, can I do something from the other location to solve the problem here? There are no problems at the other location.

Edit3: With help of the accepted solution I could do it after some time, but I'd prefer a solution without a second client

A: 

What branch are you trying to push?

By default, git push will push all of your configured tracked branches.

Try this to push just the current branch:

git push origin HEAD

gahooa
+3  A: 

You could push beta as some other branch, then go somewhere where you can check it out to resolve it.

git push origin beta:beta-temp
# on a different machine
git fetch
git checkout beta-temp
git rebase origin/beta # puts your new commits on top of the upstream
git push origin beta-temp:beta
git push origin :beta-temp # to delete it
Randal Schwartz
thank you, this helped me to solve it. This means there is no simple way to (in this case) merge from origin/beta to the local beta without checking out beta?
Sven Larson
Correct, because there's always a possibility the merge will fail, so you need to do the merge in the working tree so that you can fix the failures and commit the hybrid.
Randal Schwartz
+4  A: 

If you haven't done anything weird, then the reason for this is that the remote has a commit that you are not aware of, and allowing the push to continue would ignore that commit entirely.

Try pulling first, which will attempt to automatically merge the two commits, after which you will be able to push.

If you pull a branch that isn't currently checked out, I think it will still create a merge for you.

jleedev
A: 

Beer! All the coping you need in liquid form.

bryanbcook