Git: share the work of merging two branches

I want to merge with the forked branches of Git. It will be a lot of work because they have several hundred conflicts.

What would be the best way so that others might help me as well as work on this merger?

Usually I only do "git merge ..." and then look through all the conflicts, resolve them, and then commit. But it is local only then.

Work to resolve the conflict may take several days. I want to put my changes online already while I'm working on it.

+4
source share
2 answers

If you want others to help you, you need to put these branches on some accessible server as remote branches.

You do not need to do all the work at once. Branches dispersed at a particular point in time. So, you start working from there, but the merger is fixed gradually.

For example, you have a master branch and a very different branch called b.

if you switch to the master and do git merge b , you will get a lot of conflicts.

So, you begin to search in history where the master and b are separated. Then take, for example, the third commit into branches b and merge it

git merge <sha_in_b_branch>

You will encounter several conflicts. Eliminate them, commit, push your changes to the remote branch, and then someone else can continue. Accepts the next few commits, resolves conflicts, captures clicks, etc. Continue until you get to branch b.

+2
source

When you encountered this problem recently, I decided to rewind the expandable merge branch to the last shared commit (which I recognized with git cherry -v upstreambranch divergedbranch ) and delete all the commits that I did not want to merge (I. e. Those commits that are already present in the main branch, if with a different hash.)

So, from the list of commits in

 git rebase -i --onto lastcommoncommit upstreambranch divergedbranch 

I deleted all the commits listed in

 git log lastcommoncommit..upstreambranch 

The result is a clean, but slightly outdated topic branch containing only commits that are not yet part of the top level.

From this point on, there are basically two ways:

  • You can git cherry-pick commit the outdated butcleantopicbranch to the top HEAD column, starting with the oldest, momentless commit.
  • Restore obsolete butcleantopicbranch to senior top-level states like git rebase --onto upstreambranch@ {4 weeks ago} upstreambranch

After the rebase / cherry-pick session ends, you push the changes into the integration branch, where someone else can continue to use the same process.

+2
source

Source: https://habr.com/ru/post/1302671/


All Articles