mirror of
https://github.com/tiimgreen/github-cheat-sheet.git
synced 2025-08-09 09:26:42 +02:00
Revise description, examples for Pull Requests
This commit is contained in:
30
README.md
30
README.md
@@ -557,32 +557,22 @@ $ git stripspace < README.md
|
|||||||
[*Read more about the Git `stripspace` command.*](http://git-scm.com/docs/git-stripspace)
|
[*Read more about the Git `stripspace` command.*](http://git-scm.com/docs/git-stripspace)
|
||||||
|
|
||||||
### Checking out Pull Requests
|
### 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
|
```bash
|
||||||
$ git fetch origin '+refs/pull/*/head:refs/pull/*'
|
git fetch origin refs/pull/[PR-Number]
|
||||||
```
|
```
|
||||||
|
|
||||||
then, checkout Pull Request (i.e. 42) using
|
Acquire all Pull Request branches as local remote branches by refspec:
|
||||||
|
|
||||||
```bash
|
|
||||||
$ git checkout refs/pull/42
|
|
||||||
```
|
|
||||||
|
|
||||||
Alternatively, you can fetch them as remote branches:
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
$ git fetch origin '+refs/pull/*/head:refs/remotes/origin/pr/*'
|
$ git fetch origin '+refs/pull/*/head:refs/remotes/origin/pr/*'
|
||||||
```
|
```
|
||||||
|
|
||||||
and checkout as:
|
Or setup the remote to fetch Pull Requests automatically by adding these corresponding lines in your repository's `.git/config`:
|
||||||
|
|
||||||
```bash
|
|
||||||
$ git checkout origin/pr/42
|
|
||||||
```
|
|
||||||
|
|
||||||
and even fetch them automatically, if you add corresponding lines in your .git/config:
|
|
||||||
|
|
||||||
|
|
||||||
```
|
```
|
||||||
[remote "origin"]
|
[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/*
|
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)
|
[*Read more about checking out pull requests locally.*](https://help.github.com/articles/checking-out-pull-requests-locally)
|
||||||
|
|
||||||
### Empty Commits :trollface:
|
### Empty Commits :trollface:
|
||||||
|
Reference in New Issue
Block a user