I have a repo on github which someone else (Bob, for the sake of argument) has issued a pull request for. His code\'s not perfect, so we go through a few rounds of markups.
There are two 'squash' functions inbuilt into git
. There is git merge --squash
and there's the squash
action in git rebase --interactive
. The former doesn't retain any author or date information, just collecting all changes from a series of commits into the local working copy. The latter is annoying because it requires interaction.
The git squash extension does what you want. It rebases the current HEAD onto a specified base while automatically squashing the commits in between. It also provides a command-line option to set the message on the final squashed commit in cases where the rebase doesn't create conflicts.
Throwing this together with hub and ghi, you might be able to construct a script along these lines:
git pull upstream master
hub checkout https://github.com/$user/$repo/pull/$issue
git squash master
rev=$(git rev-parse --short HEAD)
git checkout master
git merge $rev
git commit --amend "Merged pull request #$issue"
git push upstream master
ghi close $issue $user/$repo
ghi comment $issue "Merged as $rev" $user/$repo