DEV Community

Discussion on: Git Rebase vs Merge

Collapse
 
ezrahnyanat profile image
Ezrah Nyanat

thanks for posting and making the video! great explanation. seems like git rebase is cleaner and maybe preferred?
what are some example situations when git merge is the better method to go with? (other than the example you mentioned in the video when you're not the only working on a feature branch)

Collapse
 
victoryarema profile image
Victor Yarema

The trick is that the statement "don't use rebase on shared branches" is just wrong.

Collapse
 
juristr profile image
Juri Strumpflohner

What do you mean by "is just wrong"? You suggest using rebase also on shared branches? Can you elaborate?

Collapse
 
juristr profile image
Juri Strumpflohner

It's not "cleaner" or "preferred" 🙂. It's another option to "git merge".

Rebasing (for merging) is basically always preferred when you want to have a linear git commit history. On the other side, if you're following branching models like "git flow" then that's probably not what you want, as that strategy suggests to keep merge commits. On the other side, if you're using something like "trunk based development" (trunkbaseddevelopment.com/) then you will.

Now apart from updating feature branches etc, having a linear commit history on the main branch (i.e. master) has helped me a lot for things like "git bisect" to debug problems in a larger git based monorepository.