Git merge branch at a time at a time?

I have a relatively large branch of the function that I want to combine with the master, and merging creates quite a lot of conflicts. Is there a way to combine those branches that are committed at a time, so that I can resolve one conflict at a time and check if everything works?

One solution I can think of is to use rebase instead of merge, but then the story will become flat and I don't want that. I'm fine with creating additional β€œmerge fixes," though if that helps.

+4
source share
2 answers

Instead of reloading a large branch of a function, you can instead reinstall a copy of it. When all conflicts are resolved after reinstallation, you can undo the difference:

$ git checkout -b big_feature_branch.rebased big_feature_branch
$ git rebase master big_feature_branch.rebased
# resolve all conflicts
$ git checkout big_feature_branch
$ git diff big_feature_branch big_feature_branch.rebased | git apply -
$ git ci -am "merge fix"
$ git branch -D big_feature_branch.rebased
+3
source

You can combine β€œone commit at a time,” but it would create a merge commit for each commit on another branch, which is quite heavy.

To do this, just look where you diverged from master, and in the branch, masterenter git merge <commit_id>for each commit, starting with this.

Otherwise, just resolve the big conflicts once and for all, and everyone who reads your commit history will be grateful to you.

A good way to solve this problem in this function would be to merge the regulator in your function branch.

+3
source

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


All Articles