0

Output of git push --set-upstream staging master:

! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'git@bitbucket.org:exampleOrgAbcxyz/infrastracture-staging.git'
hint: Updates were rejected because a pushed branch tip is behind its remote
hint: counterpart. Check out this branch and integrate the remote changes
hint: (e.g. 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

I have a staging remote. And I'd like to push the staging branch of my current repo to the staging remote on it's master branch.


git remote -v
composer    git@bitbucket.org:exampleOrgAbcxyz/infrastructure.git (fetch)
composer    git@bitbucket.org:exampleOrgAbcxyz/infrastructure.git (push)
origin  git@bitbucket.org:exampleOrgAbcxyz/infrastructure.git (fetch)
origin  git@bitbucket.org:exampleOrgAbcxyz/infrastructure.git (push)
staging git@bitbucket.org:exampleOrgAbcxyz/infrastracture-staging.git (fetch)
staging git@bitbucket.org:exampleOrgAbcxyz/infrastracture-staging.git (push)
Chris Stryczynski
  • 30,145
  • 48
  • 175
  • 286
  • 1
    Possible duplicate of [Cannot push to GitHub - keeps saying need merge](https://stackoverflow.com/questions/10298291/cannot-push-to-github-keeps-saying-need-merge) – TriskalJM Jun 07 '18 at 16:55

1 Answers1

1

git push staging master will attempt to push the master branch from your local repo to the master branch in the staging repo. In this case it fails because your local master is behind the remote one.

To push your staging to remote master, you want git push staging staging:master. Or git checkout staging, followed by your original command.

jingx
  • 3,698
  • 3
  • 24
  • 40
  • Thanks! I've been using that command all along anyway. I didn't realize it's the same command without the `--set-upstream`! The final command that worked was `git push --set-upstream staging staging:master`. – Chris Stryczynski Jun 07 '18 at 17:00
  • Right, `--set-upstream` is irrelevant in this issue actually. It sets up the upstream for the branch. You only ever need to specify `--set-upstream` once per branch. – jingx Jun 07 '18 at 18:28