8000 checking out pull requests · uamshare/github-cheat-sheet@ddc10be · GitHub
[go: up one dir, main page]

Skip to content

Commit ddc10be

Browse files
committed
checking out pull requests
1 parent 16a083a commit ddc10be

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,48 @@ This closes the issue and references the closing commit.
8989

9090< 8000 /code>
![Closing Repo](http://i.imgur.com/URXFprQ.png)
9191

92+
## Checking out pull requests
93+
94+
If you want to check out pull request locally, you can fetch it using that command:
95+
96+
```bash
97+
$ git fetch +refs/pull/*/head:refs/pull/*
98+
```
99+
100+
then, checkout pr (i.e. 42) using
101+
102+
```bash
103+
$ git checkout refs/pull/42
104+
```
105+
106+
Alternatively, you can fetch them as remote branches:
107+
108+
```bash
109+
$ git fetch +refs/pull/*/head:refs/remotes/origin/pr/*
110+
```
111+
112+
and checkout as
113+
114+
```bash
115+
$ git checkout origin/pr/42
116+
```
117+
118+
and even fetch them automatically, if you add corresponding lines in your .git/config:
119+
120+
121+
```
122+
[remote "origin"]
123+
fetch = +refs/heads/*:refs/remotes/origin/*
124+
url = git@github.com:tiimgreen/github-cheat-sheet.git
125+
```
126+
127+
```
128+
[remote "origin"]
129+
fetch = +refs/heads/*:refs/remotes/origin/*
130+
url = git@github.com:tiimgreen/github-cheat-sheet.git
131+
fetch = +refs/pull/*/head:refs/remotes/origin/pr/*
132+
```
133+
92134
## Cross-link issues
93135

94136
If you want to link to another issue in the same repo, simple type hash `#` then the issue number, it will be auto-linked.

0 commit comments

Comments
 (0)
0