Git: piecewise merge method for major version changes?

We are working on a serious review of our website. All work on the revised site is done in the git branch (name it 2.0), which split from the wizard some time ago. Along the way, some changes, both minor and significant, were made for development, and we would like to combine these changes in 2.0.

However, doing this as one big merge seems cumbersome - while some of the changes will be well combined, some of them are related to code that no longer exists in version 2.0, and essentially requires redefining the new features to 2.0. If unresolved conflicts occur after the merge, fixing these features can be quite difficult. We examined the use of cherry picker to bring only those changes from the master that will be well combined, and manually reprogram the main changes, but I will create problems if we ever want to merge all the changes into a 2.0 back master.

Ideally, I could do a piecewise merge from master to 2.0 - merge a group of small commits up to a specific commit, then merge one large commit and manually re-implement a certain new function, then another series in such a way that in the end, the master is completely merged into 2.0 . Is this a good approach for this situation? If so, how can I unite partly into a master, and not up to the very last command? Or is there some other, better approach I should take?

+4
source share
1 answer

You can, of course, unite in a branch in parts, referring to the hash commit, and not the name of the branch. So, say you want to merge with a specific commit in the master line — let's say its abcd1234 — you can just go into branch 2.0 and run:

 git merge abcd1234 

Using this approach, you can take as many or more commits at a time as you want. If you are faced with a conflict, you can simply resolve the conflict without accepting it all at once.

If you have changes in the master branch, which, as you know, are exclusively related to code that does not exist in your branch, and therefore are completely out of date, you can run:

 git merge --strategy=ours bcde2345 

This will create a merge commit for changes to master , but will not change the contents of the tree from what they have on 2.0 , so commits will be marked as merged, without actually doing anything.

+2
source

All Articles