Git merge branch one commit at a time?

Instead of rebasing the big feature branch, you can instead rebase a copy of that. With all the conflicts resolved after the rebase you can then pull back 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 commit -am "merge fix"
$ git branch -D big_feature_branch.rebased

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.

Tags:

Git

Merge