Joe PreviteJoe PreviteSee all posts

Automatically Squash Commits When Merging PRs

Last updated:

In the past, I didn’t think much about my commit messages or my commit history. Over time, that has changed.

Now that I commit more often, I find it helpful to squash commits when I merge PRs. This keeps the commit history clean. I like it!

Here’s how you can do it too:

  1. Go to your repo’s homepage on GitHub
  2. Click on the “Settings” tab
  3. Scroll to the “Merge button” section
  4. Check the box for “Allow squash merging”

Now when you go to merge a pull request, you’ll see an option called “Squash and merge”.

Hooray! That’s it :)