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
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
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.
What branch are you trying to push?
git push will push all of your configured tracked branches.
Try this to push just the current branch:
git push origin HEAD