DEV Community

Discussion on: On the usefulness of `git rebase`

Collapse
 
andreidascalu profile image
Andrei Dascalu • Edited

I use rebase to pull upstream base branch changes from main branch and merge to merge changes into upstream.

Rebase doesn't mess with history, it preserves it. Feature branch changes not merge in main branch should be on top of latest merge changes, not intertwined with other development commits.

Collapse
 
melvyn_sopacua_afcf30b58a profile image
Melvyn Sopacua

Exactly. It's so tiring to see those discussions of merge versus rebase, when it's the wrong discussion. Rebase and merge complement each other, they are not opposites and there is no "better" way. Yin and Yang to be applied in different scenarios.

Collapse
 
andreidascalu profile image
Andrei Dascalu

Yes, indeed, though the rebase/merge debates I've seen were always in the context of bringing in remote changes.
Pushing changes is a moot point, you can't use rebase for that anyway unless you want to rebase your branch on top of remote and then force push to replace the origin (develop/master/etc) with your rebase version.
But locally, bringing in remote changes by merging develop /master into feature results in not only history cycles impossible to properly track but also prevents using things like interactive rebase to cleanup unwanted commits and resets since all these operations only track history comun from one branch of a merge.