Monday, March 23, 2015

How to checkout Github Pull Requests locally

Today's post centers around a need I had not too long ago. While checking student's work during Google Code-In (GCI) I needed to check their branches out locally to run it. Turns out to be easier than you think:

The first is allows me to do: gco <branch>

The second file resides in .git/config -- in my case I set it up so that origin is my local working branch and upstream is the branch I forked from. If I do gco pr/1, then it will pull from upstream and checkout the working branch.

Pretty nifty eh? Don't forget to switch back to master, or whatever your main working branch is before merging or making changes!

If you prefer a more linear history, you can cherrypick commits, but still switch to master first.

No comments: