Pull requests handling

I was asked how I do pull request merging that I occur as committer but the original author stays, this keeps the commits of PRs very minimal and history a bit cleaner.

(I occasionally do this if I want just a minor fix and don’t want to ping the pull requester again)

Here is how:

  • I have a script where I can easily create a branch out of the PR so that I can locally modify it easier (it is really ugly that I cannot push my changes into the same PR but that is a github issue)
  • Now I switch to that branch, review everything and execute
  • git rebase -i HEAD~X where X is the number of commits I want to merge into one following this strategy explained here, then I do ‘squash’ and only one ‘pick’
  • Now I just need to write one commit message and get one commit which I can either merge into master OR do git cherry-pick <commit-hash> avoiding an extra merge commit

BTW: here is the bash script:

# usage: gpr 132
# this will create the pull request as a local branch issue_132
  git fetch origin refs/pull/$1/head:issue_$1
1 Like