Most of the time in repos, we see a PR, then a merge commit of that PR, which just says "Merged pull request #XXX from ...".
But recently, I saw a compacted version of that, where the avatars of the pull requester and the committer overlap, and only one clean commit shows up in the history:
How can this be done?
What I've tried and doesn't work:
- deleting the branch after the PR is accepted (PR #755)
- deleting the repo after the PR is accepted (PR #78)
UPDATE
An example of what it looks like when one of my PRs was merged that way:
Results in:
2016 April update
GitHub has introduced an option to squash commits when merging, so you can do this straight from its web UI:
Old solution
Just found this workflow from the Meteor team (coincidentally, thanks @Emily):
First, in your repository, find the
[remote "origin"]
section of the.git/config
file and add this line:Make sure to add it BEFORE the existing fetch line. Now, every time you git fetch, you'll get all the Pull Requests in the repo updated! This is a one-time change that will give you direct access to PRs forever.
Then you can just
git checkout pr/XXX
and work with the changes directly. Agit push origin
after cherry-picking will create the compact PR:The only downside is that GitHub won't automatically delete PR branches when they are closed, but that's just one click away and in exchange you get a much nicer history.
UPDATE: A further update was made by Kahmali Rose that enables GitHub to detect that the PR was merged, pretty much as if the evil Merge button was clicked: make sure to rebase and merge instead of cherry-picking.