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?
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. 🤞
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.
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.
PS: GitHub (and others?) preserve old pull requests. You can look up the details behind each squash, if you need them.
Get promoted, earn a bigger salary, work for top companies
Getting that senior title is easy. Just stick around. Being a true senior takes a new way of thinking. Do you have it?
Get a free chapter from the Senior Engineer Mindset book and a sample audiobook chapter, followed by a Senior Mindset 101 email course.
You'll get insights to apply at your work right away.
Senior Mindset Book
Get promoted, earn a bigger salary, work for top companiesLearn 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
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
By the way, just in case no one has told you it yet today: I love and appreciate you for who you are ❤️