DEV Community

Discussion on: Rebase to the future!

Collapse
 
davidgf profile image
David García

If the two commits of the feature branch have conflicts with the new one in master, I'll have to resolve conflicts twice, which is even worse if there are more. This is what I normally do:

git reset --soft HEAD~<Number of commits in my feature branch>
git commit --amend # Combine all the commits of the branch into a single one
git rebase # If there are conflicts, it's only a single commit
git merge

This is what I do when working in a feature branch + PR workflow, what do you think?

Collapse
 
jessekphillips profile image
Jesse Phillips

I need to evaluate more cases, but if each commit conflicts, you don't eliminate any merge conflict by squashing. You'll just get one big collection of conflicts to deal with.

Collapse
 
konrad_126 profile image
konrad_126

Hy David,
Yes, this happens because during rebase git re-applies the commits (from feature branch in this case), so if you have conflicts on some commit, you must resolve them before git can try to re-apply the next commit. And if you have conflicts on every commit than you'll have to do it fore every of those commits.

Your workflow helps you avoid that "multiple" conflict resolution but you lose you commits granularity since they all get squashed into a single commit.

Only one thing - checkout interactive rebase, it's a cool feature and could help you combine a message for your squashed commits.

Collapse
 
davidgf profile image
David García • Edited

Exactly, but I actually prefer to have a single commit for a feature, while I like to have the whole commit history of my branch while I'm working on it, so yeah, interactive rebase is a good choice for that :)