Linus Torvalds' Advice On Git Merges: "If you cannot explain a merge, then JUST DON'T DO IT"

Written by Michael Larabel in Linux Kernel on 21 February 2023 at 03:00 PM EST. 71 Comments
LINUX KERNEL
The Linux 6.3 merge window has been off to a good start with Linus Torvalds receiving plenty of pull requests in advance, the other early pulls all coming in quite orderly, and no colorful commentary on any of the material set for Linux 6.3 even with the likes of Microsoft Pluton (TPM2 CRB). But today Torvalds' did feel the need to share some wisdom around Git merge log message advice.

Linus Torvalds practical advice on Git merges comes down to: "if you cannot explain a merge, then JUST DON'T DO IT. It's really that simple. There is absolutely *NEVER* an excuse for merges without explaining why those merges exist."

No Git message
The lack of a message explaining this merge fired up Linus Torvalds.


Below is the Git and Linux kernel creator's commentary posted a short time ago to the LKML in response to the hardening pull request.
So I've pulled this, but while looking at it, I see commit 5c0f220e1b2d ("Merge branch 'for-linus/hardening' into for-next/hardening").

And that one-liner shortlog part is literally the whole commit message.

I've said this before, and apparently I need to say this again: if you cannot be bothered to explain *WHY* a merge exists, then that merge is buggy garbage by definition.

This really should be a rule that every single developer should take to heart. I'm not just putting random words together in a random order.

I repeat: if you cannot explain a merge, then JUST DON'T DO IT.

It's really that simple. There is absolutely *NEVER* an excuse for merges without explaining why those merges exist.

In this case, I really think that merge should not have existed at all, and the lack of explanation is because there *IS* no explanation for it.

But if there was a reason for it, then just state it, dammit, and make that merge commit look sensible.

Because right now it just looks entirely pointless. And I literally *detest* pointless merges. They only make the history look worse and harder to read.

It ended up being that the merge was of fixes for the prior Linux 6.2 cycle but the developer involved will work to express it more clearly in the future.
Related News
About The Author
Michael Larabel

Michael Larabel is the principal author of Phoronix.com and founded the site in 2004 with a focus on enriching the Linux hardware experience. Michael has written more than 20,000 articles covering the state of Linux hardware support, Linux performance, graphics drivers, and other topics. Michael is also the lead developer of the Phoronix Test Suite, Phoromatic, and OpenBenchmarking.org automated benchmarking software. He can be followed via Twitter, LinkedIn, or contacted via MichaelLarabel.com.

Popular News This Week