1098
Rebase Supremacy (programming.dev)
you are viewing a single comment's thread
view the rest of the comments
[-] Croquette@sh.itjust.works 16 points 5 months ago

I know this is a meme post, but can someone succinctly explain rebase vs merge?

I am an amateur trying to learn my tool.

[-] letsgo@lemm.ee 16 points 5 months ago

Merge gives an accurate view of the history but tends to be "cluttered" with multiple lines and merge commits. Rebase cleans that up and gives you a simple A->B->C view.

Personally I prefer merge because when I'm tracking down a bug and narrow it down to a specific commit, I get to see what change was made in what context. With rebase commits that change is in there, but it's out of context and cluttered up with zillions of other changes from the inherent merges and squashes that are included in that commit, making it harder to see what was changed and why. The same cluttered history is still in there but it's included in the commits instead of existing separately outside the commits.

I honestly can't see the point of a rebased A->B->C history because (a) it's inaccurate and (b) it makes debugging harder. Maybe I'm missing some major benefit? I'm willing to learn.

[-] ActionHank@sopuli.xyz 3 points 5 months ago* (last edited 5 months ago)

I would advocate for using each tool, where it makes sense, to achieve a more intelligible graph. This is what I've been moving towards on my personal projects (am solo). I imagine with any moderately complex group project it becomes very difficult to keep things neat.

In order of expected usage frequency:

  1. Rebase: everything that's not 2 or 3. keep main and feature lines clean.
  2. Merge: ideally, merge should only be used to bring feature branches into main at stable sequence points.
  3. Squash: only use squash to remove history that truly is useless. (creating a bug on a feature branch and then solving it two commits later prior to merge).

History should be viewable from log --all --decorate --oneline --graph; not buried in squash commits.

load more comments (6 replies)
load more comments (24 replies)
this post was submitted on 04 Apr 2024
1098 points (98.1% liked)

Programmer Humor

19187 readers
1095 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 1 year ago
MODERATORS