Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple devs pushing to same change

Tags:

git

gerrit

I'm struggling to find a good workflow when two or more people are pushing patch-set's to the same change-set in Gerrit.

I am trying to accomplish this with command-line Git commands (no git-review, IDE, etc).

Pulling down the latest patch-set from the Gerrit server for a particular change is easy enough, but from there I'm not sure.

I would think the process would be:

  • fetch latest patch-set for change from server
  • rebase against latest patch-set
  • push

But during the rebase it marks all incoming changes as conflict, even if they weren't altered locally.

Perhaps this is related to the fact that the latest patch-set downloaded is not reachable by HEAD locally.

Can anyone suggest how multiple developers can work on the same change?

EDIT: The answer to this question are shown with the techniques described in: How to change a patchset and push it as a new one?

like image 309
Jonathan.Brink Avatar asked Nov 19 '15 20:11

Jonathan.Brink


People also ask

Can two developers work on the same branch?

For every discreet feature (bug, enhancement, etc.), a new local branch is made from dev. Developers don't have to work on the same branch, since each feature branch is scoped to only what that single developer is working on.

What is the main issue with git rebase when working with multiple developers?

recommends that rebase should not be done on branch shared between developers. I understand that, because a developer might first merge the code and then he decides to rebase the code, other developers might end up in creating multiple duplicates commits as explained in Perils of Rebasing.

How can I work on same branch?

Multiple people can work on the same branch at the same time. When you pull (or have the other person push) their changes to you git will merge the changes together resulting in a branch with both of your changes.


1 Answers

Your problem is gerrit itself. A changeset in gerrit is a single git commit that's rewritten whenever the changeset is changed as a part of the review process. As such, you get a history like this:

reviewed branch head --- changeset A, first revision
                     \-- changeset A, second revision
                      \- changeset A, third revision

Now, with the workflow you sketched in your question, you attempt to create this history:

reviewed branch head --- changeset A, first revision --- changeset A, second revision

Any change that is present in both revisions will conflict with itself if you do this.

The gerrit way to work around this is to fetch the latest revision of the changeset, amend the changeset, then push it as a new revision of the changeset, replacing the previous changeset, hoping that no other developer has worked on the same changeset in the meantime. The last part is where a gerrit based workflow fails to achieve what is trivial to do with pure git: Developers can't work in parallel on the same changeset. This is in stark contrast to pure git, where all developers can freely create new commits, branch, and merge however they please, and git is able to put all the pieces back together. But for this to work, commits must be constant in git, a principle that is violated by the gerrit workflow.

If you ask me, the best thing to do is to avoid using gerrit. It's basic workflow is broken, and you are much better of using pure git in the way that it is used by the linux developers.

like image 51
cmaster - reinstate monica Avatar answered Oct 13 '22 16:10

cmaster - reinstate monica