Why I Prefer Regular Merge Commits Over Squash Commits

<p>&ldquo;Wow, that&rsquo;s so cool!&rdquo;</p> <p>I&rsquo;ll always remember seeing my first squash commit.</p> <p>When I first joined a large engineering organization with more than 200 members, the squash commits were the first thing I noticed.</p> <p>To me, the consistent use of squash commits across the company screamed &ldquo;professionalism&rdquo; and &ldquo;we know what we&rsquo;re doing here!&rdquo;</p> <p>It took me about a month to realize that I really,&nbsp;<em>really</em>&nbsp;didn&rsquo;t like squash commits, and I started longing for good, old-fashioned merge commits.</p> <h1>Comparing Squash vs. Merge Git Commits</h1> <p>As a refresher, the difference between a &ldquo;squash commit&rdquo; and a &ldquo;merge commit&rdquo; is that a regular &ldquo;merge&rdquo; includes all of the Git commits in the history of the target branch, while &ldquo;squash&rdquo; flattens them to one commit.</p> <p>Confusingly, &ldquo;squash&rdquo; isn&rsquo;t its own command. Instead, you can choose &ldquo;squash and merge&rdquo; or &ldquo;squash and rebase&rdquo; as an option when you&rsquo;re running the&nbsp;<code>git merge</code>&nbsp;or&nbsp;<code>git rebase</code>&nbsp;commands, respectively.</p> <p>By default, a pull request (PR) will be a merge commit, so after the PR is merged then the entire history of the working branch will be merged in, plus an additional commit (&ldquo;Merge pull request #21 from branch&hellip;&rdquo;).</p> <p>On the other hand, you can set your repository to &ldquo;squash and merge&rdquo; by default, meaning merged PRs will result in only a single commit each, instead of bringing over all the commits from the working branch.</p> <p><a href="https://betterprogramming.pub/why-i-prefer-regular-merge-commits-over-squash-commits-cadd22cff02c">Website</a></p>
Tags: Coding Squash