From f7a020121f9ec1339f1dfb7c33e9c5a2e81507c5 Mon Sep 17 00:00:00 2001 From: jordanmccullough Date: Sat, 17 May 2014 16:20:06 -0600 Subject: [PATCH] Revise description, examples for Pull Requests --- README.md | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 1b82c0f..a359f71 100644 --- a/README.md +++ b/README.md @@ -557,32 +557,22 @@ $ git stripspace < README.md [*Read more about the Git `stripspace` command.*](http://git-scm.com/docs/git-stripspace) ### Checking out Pull Requests -If you want to check out pull request locally, you can fetch it using that command: + +Pull Requests are special branches on the GitHub repository which can be retrieved locally in several ways: + +Retrieve a specific Pull Request and store it temporarily in `FETCH_HEAD` for quickly `diff`ing or `merge`ing: ```bash -$ git fetch origin '+refs/pull/*/head:refs/pull/*' +git fetch origin refs/pull/[PR-Number] ``` -then, checkout Pull Request (i.e. 42) using - -```bash -$ git checkout refs/pull/42 -``` - -Alternatively, you can fetch them as remote branches: +Acquire all Pull Request branches as local remote branches by refspec: ```bash $ git fetch origin '+refs/pull/*/head:refs/remotes/origin/pr/*' ``` -and checkout as: - -```bash -$ git checkout origin/pr/42 -``` - -and even fetch them automatically, if you add corresponding lines in your .git/config: - +Or setup the remote to fetch Pull Requests automatically by adding these corresponding lines in your repository's `.git/config`: ``` [remote "origin"] @@ -597,6 +587,12 @@ and even fetch them automatically, if you add corresponding lines in your .git/c fetch = +refs/pull/*/head:refs/remotes/origin/pr/* ``` +For Fork-based Pull Request contributions, it's useful to `checkout` a remote branch representing the Pull Request and create a local branch from it: + +```bash +$ git checkout pr/42 pr-42 +``` + [*Read more about checking out pull requests locally.*](https://help.github.com/articles/checking-out-pull-requests-locally) ### Empty Commits :trollface: