[Geany-devel] Just another github question: Easy way to pull pull reuqest for testing purposes?

Matthew Brush mbrush at xxxxx
Sat Dec 31 12:03:56 UTC 2011

On 12/31/2011 01:31 AM, Frank Lanitz wrote:
> Hi folks,
> During the last weeks I merged a couple of pull requests into
> geany-plugins. During this work I found it a bit annoying not finding a
> easy way to pull the pull request directly and test it locally and maybe
> add it to me git repo. Is there any direct way on doing this instead of
> going to offerer's github page and clone the complete repo?

I'm going to take a few minutes to go through it in order to document, 
in exchange *YOU must post this on the Wiki* (after testing) :)

Ok, you have your "official" `geany-plugins` repository from doing:

   $ git clone git at github.com:geany/geany-plugins.git
   $ cd geany-plugins/

Then say you want to check out pull request #7[1], it's from user
`cushy007` on his/her fork, so:

   $ git remote add -f \
       cushy007 https://github.com/cushy007/geany-plugins.git

Now you have their remote and have fetched their branches (I think). 
Then, in this case the requester is working straight on the `master` 
branch (tsk tsk), so you need to pull it into a different local branch, 
so maybe:

   $ git checkout --track -b cushy007-master cushy007/master

Which says "checkout a new branch named `cushy007-master` from the 
remote `cushy007` and branch `master` and track it.

Now you can try out the changes and make some fixes, maybe with new 
commits.  If it's out of date with the main `master` branch, you can 
rebase it on top (which will probably make the Pull Request feature not 
realize you've "accepted" the pull request on Github):

   $ git rebase master
   [hopefully not fix conflicts]

But this will change the history compared to the Pull Requester's 
history, so ideally you will not do this and worst case there will be a 
merge commit (I don't really understand this but it seems to be how it 

Then get back to the main `master` branch when you're done and merge 
this Pull Request in:

   $ git checkout master
   $ git merge cushy007-master

Sometimes if the pull request is not really usable, like the author is 
not specified, or there's lots of noise, you can just pull in their 
branch as above, and then switch to the master branch and cherry pick 
their specific commit:

   $ git checkout master
   $ git cherry-pick e6a41b574fdbed04fc5c582d90b26d8d727898dd

Which will strip that commit out of their branch and apply it to master 
(ideally).  Then if you need to set the author properly or make changes, 
you can just do:

   [make changes]
   $ git commit --amend --author "Real Proper Author <auth at email.org>"

Which will again probably clobber their history, but they should've made 
a better patch :)

Then just push it as normal to the main repository:

   $ git push origin master

Finally, go to Github to see if the Pull Request was automatically 
closed or whether you should close it manually, noting any applicable 
commits in the comments.

At the end, if you don't think you'll use `cushy007`'s remote any more, 
you can remove it (though it doesn't hurt to leave it):

   $ git remote rm cushy007

P.S. I'm not a Git master, I just kind of walked through this while 
writing and using my few experiences with pull requests, so it's 
probably not 100% the best way.

Matthew Brush

[1] https://github.com/geany/geany-plugins/pull/7

More information about the Devel mailing list