I have a relatively big feature branch that I want to merge with master, and the merge produces quite a lot of conflicts. Is there a way to merge those branches one commit at a time so I could resolve one conflict at a time and check if everything's working?
One solution I can think of is to use rebase instead of merge, but then the history will become flat and I don't want that. I'm ok with creating additional "merge fix" commits, though, if it helps.
You could merge "one commit at a time", but it would create a merge commit for each commit you have on the other branch, which is quite heavy. To do that, just look at where you diverged from master , and while on the master branch, issue git merge <commit_id> for each commit starting from that.
Merges a branch into the current branch, creating a merge commit. Use git checkout <target-branch> to switch to the branch into which you want to merge.
To merge branches locally, use git checkout to switch to the branch you want to merge into. This branch is typically the main branch. Next, use git merge and specify the name of the other branch to bring into this branch. This example merges the jeff/feature1 branch into the main branch.
You could merge "one commit at a time", but it would create a merge commit for each commit you have on the other branch, which is quite heavy.
To do that, just look at where you diverged from master
, and while on the master
branch, issue git merge <commit_id>
for each commit starting from that.
Otherwise, just resolve the big conflicts once and for all, and everyone reading your commit history will thank you.
A good way to address this problem in the feature would be the regulary merge master in your feature branch.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With