0

I am using gerrit for a project, I have a feature branch locally that has two commits (1) (2) diverged from remote develop branch as show in the image

Feature branch.

Before I could push my changes to remote develop, I pulled from remote, merged the changes as shown in the node (m). Then, I tried to push to remote, I got an error message saying there are conflicts between (1) (2) and (3) (4). I don't understand why this happened, I thought git push only pushes the merged one (m) to the remote. So to solve this, I have to reset the merge, rebase to the develop, then push, but I feel there should be a better way to deal with this.

EDITS: I already solved the issue by rebase, which is exactly @Marcelo suggested here, cannot go back to get the exact error message, but what happened is when I pull there was conflicts, I fixed the conflicts and merged, and then I type git status it says i am 1 commit ahead of remote, so i did git push origin HEAD:refs/for/developer, and Gerrit won't let me push by saying there is conflicts for commit (1) and (2), not commit (m) as shown in my image... I don't understand this part as i thought push only pushes the commits that are ahead of remote, why the remote says there are conflicts for commit (1) and (2), i suspect that is because of Gerrit's special settings.

shelper
  • 10,053
  • 8
  • 41
  • 67
  • 1
    What does the error message exactly say? They have been merged. How could there be conflicts? – ElpieKay May 21 '18 at 15:46
  • 1
    My guess is somebody else pushed something while you were doing the merge, so your push was refused. But without the actual error message, and the commands you executed, it's hard to tell. – jingx May 21 '18 at 16:41
  • 1
    As ElpieKay have said, you need to write all commands you have used and the exact error message you got. – Marcelo Ávila de Oliveira May 21 '18 at 16:46

1 Answers1

0

To know exactly what happened you need to add the commands you've used and the exact error message you've got (if you update your question I can update my answer as well).

You should not have merged the develop branch to your local branch, you must have rebased your local branch instead:

git checkout feature
git rebase origin/develop
git push origin HEAD:refs/for/develop