r/ProgrammerHumor • • Oct 16 '26

Meme lostTheMergeRace

Post image
1.5k Upvotes

111 comments sorted by

View all comments

14

u/Apprehensive-Lychee2 Oct 16 '26

You guys use Rebase??

9

u/NamityName Oct 17 '26

Yes. It is safer as the resulting merge is a simple fast forward and not a 3-way merge

6

u/Apprehensive-Lychee2 Oct 17 '26

Can you actually explain that a little more, I have never has a situation occur where rebase was preferred. 

7

u/NamityName Oct 17 '26

The normal merge is called a 3-way merge. It compares 3 commits to determine what the new commit will look like: the HEAD of the branch being merged, the HEAD if the branch being merged into, and the common ancestor. The end result is a commit that does not necessarily match either of the two branch heads.

However, if the common ancestor of the feature branch being merged is the HEAD of the branch being merged into, Git does a fast forward merge instead of a 3-way merge. It will simply move the base branch's HEAD to the HEAD of the branch being merged. The base branch will exactly match the feature branch, guaranteed. No questions. No funny business. No side effects. The code you reviewed in the feature branch will be the code after the merge.

Getting back to rebasing. A rebase will move the branch being rebased and all of its commits going back to the common ancestor to the HEAD of the base branch. The rebase process will resolve any conflicts. Then, when you merge, git will do a fast forward merge instead of a 3-way merge.

3

u/__Invisible__ Oct 17 '26

only fast forward allowed, so we rebase master on our branch and merge again.

3

u/5up3rj Oct 16 '26

My boss loves rebase. Only wants rebase

8

u/BananafestDestiny Oct 16 '26

All my homies hate merge bubbles.

3

u/Sixshaman Oct 17 '26

Yes, because this way, git history doesn't look like tangled spaghetti XD