Skip navigation
2011

I just noticed today that github has changed the way it's pull requests work, so it is now possible to merge pull requests using:

 

git pull --rebase upstream pull/$no/head

 

(where $no is the pull request number)

 

I wrote a simple function that takes pull request numbers as parameters that I thought I would share in the hope it would make life easier for anyone who has to merge a lot of pull requests.

 

pull() {
  cmd="git fetch upstream "
  for var in "$@"
  do
    cmd="$cmd pull/$var/head:pullRequest$var"
  done
  
  $cmd
  
  for var in "$@"
    do
    git checkout pullRequest$var
    git rebase master
    git checkout master
    git merge pullRequest$var
    git branch -D pullRequest$var
  done
}

After putting this in your bashrc file you can use it as follows:

 

pull 251 252 253 

 

This will fetch all the pull requests into temporary branches, check them out, rebase them and then merge them into master.