Search code examples
gitgerrit

'Your branch is ahead of 'origin/remote-branch' by 37 commit.' after merge


I have done the below steps:

>git checkout remote-branch-test
>git pull
>git checkout remote-branch
>git pull
>git merge remote-branch-test
Automatic merge failed; fix conflicts and then commit the result.

resolved the conflict

>git add .
>git commit
>git push origin remote-branch
**! [remote rejected]   remote-branch -> remote-branch (you are not allowed to upload merges)
error: failed to push some refs to ....

When I do a git status on my remote server

>git status
On branch remote-branch
Your branch is ahead of 'origin/remote-branch' by 37 commits.
  (use "git push" to publish your local commits)

I am not able to push the changes to remote

what I am missing here?


Solution

  • Solve the problem by following Steps :

    git fetch

    git checkout origin/remote-branch

    git merge --squash origin/remote-branch-test

    git commit

    git push origin HEAD:refs/for/remote-branch