user3216016 user3216016 - 9 months ago 87
Git Question

Master branch 4 ahead. Cannot push. Git

I get the error below when trying to push my commit. I have tried pulling then pushing again but it doesn't seem to work.

git -c diff.mnemonicprefix=false -c core.quotepath=false push -v --tags --set-upstream origin master:master
Pushing to https:*"repository"*
To https**"repository"**
! [rejected] master -> master (non-fast-forward)

error: failed to push some refs to *"repository"*
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

Answer Source

You have to use git pull before pushing.

You have to update your local branch with the remote branch before pushing a change to remote.