-
-
Save ar5had/69f9dbb8467a7e4960827d9a7a2d65cd to your computer and use it in GitHub Desktop.
Revisions
-
adam-p revised this gist
Jan 8, 2015 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -46,6 +46,8 @@ Now merge the PR: $ git merge pr37 ``` NOTE: You should edit the merge commit message to reference the PR (using, say `#37` in it). Now push: ``` $ git push upstream HEAD:master -
adam-p renamed this gist
Dec 31, 2014 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
adam-p created this gist
Dec 10, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,56 @@ It's not immediately obvious how to pull down the code for a PR and test it locally. But it's [pretty easy](https://help.github.com/articles/checking-out-pull-requests-locally/). (This assumes you have a remote for the main repo named `upstream`.) **Getting the PR code** 1. Make note of the PR number. For example, Rod's latest is PR #37: https://github.com/Psiphon-Labs/psiphon-tunnel-core/pull/37 2. Fetch the PR's pseudo-branch (or bookmark or rev pointer whatever the word is), and give it a local branch name. Here we'll name it `pr37`: ``` $ git fetch upstream pull/37/head:pr37 ``` 3. Switch to that branch: ``` $ git checkout pr37 ``` 4. Compile and test. If the PR code changes and you want to update: ``` # Do this while in the pr37 branch $ git pull upstream pull/37/head ``` (I try to avoid `pull` and instead use `fetch`+`merge`, but... I don't know how to do it for this.) **Merging the PR** You can use the Github web interface, but there's a [TOCTOU](https://en.wikipedia.org/wiki/Time_of_check_to_time_of_use) problem: If the pull-requester changes their master (or whatever they're PRing from) between the time you test and the time you merge, then you'll be merging code that you haven't reviewed/tested. So let's do it on the command line. First, checkout the upstream master code: You'll only do this the first time -- it creates the local `upstream_master` branch, tracks it to `upstream_master`, and switches to the branch: ``` $ git checkout -t -b upstream_master upstream/master ``` After the first time you'll just do: ``` $ git checkout upstream_master ``` Now merge the PR: ``` $ git merge pr37 ``` Now push: ``` $ git push upstream HEAD:master ``` (You can't just `git push` because your local branch name is different than the remote.) Done! Refresh the Github PR page and you'll see that the PR is now merged+closed.