Collaboration in resolving merger conflicts

Scenario: Have a branch on the (active) release in git,

Sequence:

  • Bob makes changes to R1 , commits, pulls R1 and presses R1 on the common. Does not upgrade R2 on shared resources.
  • Jane makes changes to R1 , commits.
  • Jane pulls R1 out of the public domain, deals with any conflicts, pushes R1 .
  • Once again a few times Step 1
  • Jane said they need to upgrade R2 with fixes from R1
  • Jane pulls R1 and R2 out of common
  • Jane combines R1 to R2 locally. Combine conflicts in some area of โ€‹โ€‹the code that Bob worked on.

Jane must take R2 out of the public domain and process the merge before she can click. But she does not know what to do with Bob's changes.

Branches: R1 , R2

State of Shared Repository C1 - Bob | C2-+ - Jane | | | C3 - George | | | C4 C5 | - Bob | | C6 | - Jane [R1] | C7 - Alice [R2] 

Bob and Jane make changes to R1

Jane then wants to merge R1 into R2 to update the latest version. She solves the merge conflicts caused by her changes, however she does not know how to resolve the conflicts caused by the changes Bob made.

Is there a way for Jane to use git and for Bob to complete the merge?

I know very well that Bob has already merged his changes into R2 , but suppose this is not so.

Possible workarounds (search for something better)

  • Jane calls Bob to his desk, and Bob then resolves the conflict. Difficult when telecontrol
  • Jane saves conflicting files and email to Bob, Bob commits the file and sends them back to Jane, who then uses them in her commit.
+8
git
source share
4 answers

Assuming Bob is locked and Jane wants to move the problem, Jane does her best to complete the merge.

  $ git fetch
 $ git checkout R2
 $ git merge --ff-only origin / R2
 $ git checkout -b wip / R2-with-R1 

Above the napkin stands for work in progress, and this is an agreement that informs the team that wood and history are subject to radical changes. Perhaps Jane really wants Bob to take a look at her resolutions, which affect his code from R1, before integrating them into the baseline. (Note: this is an anti-pattern, the best approach is automated tests that protect the desired behavior for new code in R1 and allow developers other than Bob to merge confidently.)

Jane is doing her best to merge.

  $ git merge origin / R1
 $ hack
 $ git add ..
 $ hack
 $ git add .. 

The wip / R2-with-R1 splitter can even contain multiple checkpoint-style transactions. Another good signal for everyone who will contain it will allow the team to understand that it is speculative.

  $ git commit -m 'FIXME: fix conflicts in Potrzebie' 

When she is ready for Bob to look at her, she pushes her into the vault, which they can see as

  $ git push --set-upstream origin wip / R2-with-R1 

The --set-upstream option is if they should work together on a new branch.

She then launches her mail user agent.

  To: Bob
 From: jane
 Subject: speculative merge: wip / R2-with-R1

 Bob: please look over my attempted merge in the subject branch and make
 any necessary fixes that I may have overlooked.

 I am particularly concerned about my Potrzebie conflict-resolutions.
 Changes there always seem to bite us one way or the other.

 Thanks,
 Jane 

After Bobs corrects and retrieves, the story will resemble

  $ git lola
 * 77d472c (origin / wip / R2-with-R1) fix by Bob
 * ba1eb24 (HEAD, wip / R2-with-R1) FIXME: merge 2
 * 80c207d FIXME: merge 1
 | \ |
 |  * 2cf6ad4 (origin / R1, R1) R1 # 2
 * |  137b39d (origin / R2, R2) R2 # 2
 * |  cb9a761 R2
 ... 

At this point, Jane wants to keep the merger, but does not want to keep the ugly checkpoint. Twisting back to fixing a merge requires a bit of care.

  $ echo Merge R1 into R2 |  \
   git commit-tree origin / wip / R2-with-R1 ^ {tree} \
   -p $ (git rev-parse origin / R1) -p $ (git rev-parse origin / R2)
 84b177c498bc635612b66932f3d41096999e6d3f

 $ git checkout R2
 Switched to branch 'R2'

 $ git merge --ff-only 84b177c498bc635612b66932f3d41096999e6d3f
 Updating 137b39d..84b177c
 Fast forward
 ... 

It leaves a story

  $ git lola
 * 84b177c (HEAD, R2) Merge R1 into R2
 | \ |
 |  |  * 77d472c (origin / wip / R2-with-R1) fix by Bob
 |  |  * ba1eb24 FIXME: merge 2
 |  |  * 80c207d (wip / R2-with-R1) FIXME: merge 1
 |  |  | \ |
 |  | / /
 |  |  /
 |  | /
 | / |
 * |  2cf6ad4 (origin / R1, R1) R1 # 2
 |  * 137b39d (origin / R2) R2 # 2
 |  * cb9a761 R2
 ... 

and R2 now has the same tree by construction as the final Bobs tree.

+4
source share

In addition, Jane calls Bob on the table and looks at the changes on his computer, I donโ€™t think it can be done in git.

When the merge is resolved, you create a new commit, and all this happens locally. Jane could make a merger and decided not to push the changes on the remote control. Until the merge lock is pressed, there is no way to know if someone else has merged with their copy of the remote. Jane must allow commits to complete the merge, and this only happens locally.

It is not possible to merge the changes in the remote control anyway. Suppose I start working with a repo and pull changes before Bob finishes conflict resolution. What then?

Another way for Jane to know if she will allow commits is that she has a set of tests to run. Then she knows that she was mistaken when the tests began to fail.

+2
source share

If I understand the sequence of actions correctly, it looks like this:

  • Bob makes changes to R1, commits, merges with his copy of R2, and encourages sharing.
  • Jane makes changes to R1, commits, merges with her copy of R2 and tries to click on a common one, but gets an outdated error.
  • Jane must take R2 out of the public domain and process the merge before she can click. But she does not know what to do with Bob's changes.

In this situation, Jane and Bob could do the following:

  • Jane can create a branch in common with her changes in R2:

     git push origin R2:R2-from-Jane 
  • Jane can call / email / IM Bob and ask him to join in his changes.
  • Bob sighs displeasedly to do it again , why is Jane always so nervous because her changes merge with him? This is stupid ... then allows merging with the Jane branch from the server:

     git fetch origin R2-from-Jane git checkout R2 git merge R2-from-Jane git push git branch -d R2-from-Jane 
  • Bob answers Jane to report that the merger is complete.
  • Jane removes the temporary branch from the server:

     git push origin :R2-from-Jane 

    and then answers to thank Bob. And ask him to go for coffee someday, maybe ...

(Obviously, Bob could also deal with deleting Janeโ€™s temporary branch on the server, but that didn't match the description either.)

+1
source share

We are in a similar situation.

Here is the way that we found, somehow working after several different unsuccessful approbations. The point was how to share conflicting hunks with a remote repository.

  • Jane creates two branches from the top of R2 and combines R1 on them with a set of โ€œadditionalโ€ merge strategies,

     $ git branch wip/reference R2 $ git checkout wip/reference $ git merge -s recursive -X theirs R1 $ git branch wip/merging R2 $ git checkout wip/merging $ git merge -s recursive -X ours R1 
  • Now

     $ git diff wip/reference..wip/merging 

    shows how R1 would collide with R2 because the merge strategy "-s recursive -X ours / theirs" causes conflicting chunks to be automatically resolved by approving our / their version.

  • Jane makes the necessary changes to wip / merging to resolve the "virtual" conflicts caused by her previous changes, and leaves Bob untouched.

  • Then Jane pushes wip / reference and wip / merging and calls / IM / email / owlpost Bob to get them.

  • Bob checks virtual conflicts and resolves halfway Jane made and makes further changes to the conflicts that occurred in his past changes being called.

  • He then combines wip / merging back to R2 if he feels that everything looks good, or perhaps ask George / Alice to make additional permissions.

We are still exploring how this affects subsequent merges (i.e. if git reerre works correctly).

+1
source share

All Articles