Skip to content

Commit 85f9152

Browse files
author
Rafal Chmiel
committed
Merge pull request tiimgreen#3 from mechmind/master
Checking out pull requests locally
2 parents 5034382 + 7af0205 commit 85f9152

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
@@ -91,6 +91,48 @@ This closes the issue and references the closing commit.
9191

9292
![Closing Repo](http://i.imgur.com/URXFprQ.png)
9393

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

96138
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)