Swizec Teller - a geek with a hatswizec.com

Senior Mindset Book

Get promoted, earn a bigger salary, work for top companies

Senior Engineer Mindset cover
Learn more

    Squash merge? Really!?

    Yes, squash merge. I hated it, now I love it. Squash merge is your friend.

    Fellow reader Alex wrote in after the Why trunk-based development is best email – He noticed that we squash merge our code and was ... disgusted? Surprised? Worried for our sanity?

    But squash merging? I know this isn’t the subject of the email, but what about losing all of that granular git history?

    Where I work right now we put a lot of value on git hygiene and git history. We try to have clean, well organised commits and don’t squash merge. We favour re-writing commits in a PR vs adding a “fixed what I broke in last commit” commit.

    Alex is right. A clean git history matters. But let me ask you this, how many of the hundreds of pictures you take on vacation do you ever look at again?

    Why git history matters

    Git history is a record of how your software came to be. A way to look at code and ask "But why?".

    That's if the description is good. At the very least you can find out who made a change and ask what they were thinking.

    At my company we try to link every pull request to a JIRA story. That way we can answer questions without having to remember. Even after people leave.

    You can also use git history as a set of checkpoints. A way to deploy or run the code at a point in history.

    In reality software and ecosystems move ever forward and running old code almost never works. But you can revert a deploy or two and go back a few days before you broke prod. 🤞

    Keep the important history, drop the rest

    An abundance of data is not the same as information. How detailed of a history do you need? Do you wanna know when I farted, banged my head against the keyboard, or just when the feature finally worked?

    I've been reading a book on medical health records and one of the bigger problems is that doctors record too much data. They can't know what's gonna be useful tomorrow so they write down everything. Later, nobody reads that shit.

    That's why your doctor asks stupid questions instead of reading the chart. There's too much! They can't find the important bits.

    Same is true for your git history.

    Do you want everything or just the meaningful changes? Are you gonna read a sea of commits?

    Wouldn't it be nice, if every commit on main was ready to go? Compiling, running, passing tests, deployable to prod. Every commit works, achieves a unit of functionality, and describes its purpose. No surprises.

    That's what squash merge achieves. Throw away the in-progress work and merge when it's all ready. You won't miss the detailed history, I promise.

    It's liberating! Lets you focus on the work instead of recording the work. Enjoy the squalor, keep moving, then clean up with the press of a button 😌

    Plus if you're not rewriting commits, two people can work on the same branch.

    Cheers,
    ~Swizec

    PS: GitHub (and others?) preserve old pull requests. You can look up the details behind each squash, if you need them.

    Published on January 27th, 2023 in Teams, Productivity, Mindset, Velocity, Reader Question

    Did you enjoy this article?

    Continue reading about Squash merge? Really!?

    Semantically similar articles hand-picked by GPT-4

    Senior Mindset Book

    Get promoted, earn a bigger salary, work for top companies

    Learn more

    Have a burning question that you think I can answer? Hit me up on twitter and I'll do my best.

    Who am I and who do I help? I'm Swizec Teller and I turn coders into engineers with "Raw and honest from the heart!" writing. No bullshit. Real insights into the career and skills of a modern software engineer.

    Want to become a true senior engineer? Take ownership, have autonomy, and be a force multiplier on your team. The Senior Engineer Mindset ebook can help 👉 swizec.com/senior-mindset. These are the shifts in mindset that unlocked my career.

    Curious about Serverless and the modern backend? Check out Serverless Handbook, for frontend engineers 👉 ServerlessHandbook.dev

    Want to Stop copy pasting D3 examples and create data visualizations of your own? Learn how to build scalable dataviz React components your whole team can understand with React for Data Visualization

    Want to get my best emails on JavaScript, React, Serverless, Fullstack Web, or Indie Hacking? Check out swizec.com/collections

    Did someone amazing share this letter with you? Wonderful! You can sign up for my weekly letters for software engineers on their path to greatness, here: swizec.com/blog

    Want to brush up on your modern JavaScript syntax? Check out my interactive cheatsheet: es6cheatsheet.com

    By the way, just in case no one has told you it yet today: I love and appreciate you for who you are ❤️

    Created by Swizec with ❤️