Autosquash
Autosquash automatically updates and merges your pull requests.
Autosquash is a simple and opinionated JavaScript GitHub action integrating especially well in repositories with branch protections with strict status checks protecting against semantic conflicts.
Pull requests with the autosquash
label will be:
Focus has shifted to the development of Auto-update, the successor of Autosquash.
Indeed, GitHub now supports pull request auto-merge out of the box. The only thing not taken care of by GitHub (yet) is automatically updating a pull request when its base branch receives new commits and that's exactly what Auto-update does.
autosquash
label to pull requests you want to merge.Autosquash favors squash and merge over regular merge or rebase and merge for the following reasons:
GitHub handles merge commits graciously. Indeed, it has a web interface for resolving merge conflicts and it helps the reviewer not wasting time reviewing conflict-free merge commits by displaying this:
On the other hand, rebasing a pull request rewrites its Git history and GitHub doesn't like that. For instance, clicking on a notification concerning changes in a pull request with rewritten history will give you this:
The same thing will happen if you click on the file link of a line comment but the pull request was rebased since the comment was posted.
Another minor inconvenience with rebase and merge is that it's harder, when looking at the list of main
commits, to know which commit comes from which pull request.
You have to go to the actual commit page for GitHub to show you which pull request had it.
With regular merge or squash and merge, GitHub adds a pull request link in the commit title so the pull request is always a single click away from the list of commits.
git rebase
and git push --force
are useful when prototyping a feature locally.
They also allow to create a pull request with a clean initial Git history.
But once you ask for a review and start collaborating on a pull request, it's best to stop using these commands.
This eliminates the rebase and merge option and leaves us with the regular merge or squash and merge ones.
It's nice to make small and atomic commits inside a big pull request but it's even nicer to make small and atomic pull requests.
The pull request is the unit of change:
main
when merged.git bisect
if they land individually on main
.By the time a pull request is ready to be merged, its Git history will often contain commits addressing review comments, fixing tests, typos, or code formatting.
There is no point in making these commits part of main
's history.
We would rather gather all the pull request's commits into a single cohesive commit and put it on top of main
.
And that's where the Autosquash WALL·E inspired logo and :package: emoji come from!
The regular merge option doesn't help keeping main
's history clean, so we're only left with the squash and merge one.