1GIT-PR(1)                         Git Extras                         GIT-PR(1)
2
3
4

NAME

6       git-pr - Checks out a pull request locally
7

SYNOPSIS

9       git-pr[-m|--merge] <number> [<remote>]
10       git-pr   [-m|--merge]  &lt;[remote]:number&gt;...<br>git-pr[-m|--merge]
11       &lt;url&gt;...<br>git-pr clean`
12

DESCRIPTION

14       Creates a local branch based on a GitHub pull request  number  or  URL,
15       and switch to that branch afterwards.
16

OPTIONS

18       <remote>
19
20       The name of the remote to fetch from. Defaults to origin.
21
22       <url>
23
24       GitHub       pull       request       URL       in      the      format
25       https://github.com/tj/git-extras/pull/453.
26
27       -m | --merge
28
29       Checkout a merge commit against the branch the pull request is  target‐
30       ing.
31

EXAMPLES

33       This checks out the pull request 226 from origin:
34
35
36
37           $ git pr 226
38
39           remote: Counting objects: 12, done.
40           remote: Compressing objects: 100% (9/9), done.
41           remote: Total 12 (delta 3), reused 9 (delta 3)
42           Unpacking objects: 100% (12/12), done.
43           From https://github.com/tj/git-extras
44            * [new ref]         refs/pull/226/head -> pr/226
45
46           Switched to branch ´pr/226´
47
48
49
50       This pulls from a different remote:
51
52
53
54           $ git pr 226 upstream
55
56
57
58       This does the same thing as the command above:
59
60
61
62           $ git pr upstream:226
63
64
65
66       You can also checkout a pull request based on a GitHub URL:
67
68
69
70           $ git pr https://github.com/tj/git-extras/pull/453
71
72           From https://github.com/tj/git-extras
73            * [new ref]         refs/pull/453/head -> pr/453
74           Switched to branch ´pr/453´
75
76
77
78       You could even pull multiple pull requests via the GitHub URL or the ID
79       with remote specified:
80
81
82
83           $ git pr upstream:226 upstream:443
84           $ git pr upstream:443 https://github.com/tj/git-extras/pull/453
85
86
87
88       Note that git pr PR-A PR-B is equal to:
89
90
91
92           $ git pr PR-A
93           $ git pr PR-B
94
95
96
97       Therefore, if one of the pull request is failed to pull,  this  command
98       will  still  go  ahead and pull the others. The final exit code will be
99       decided by the result of the final pulling.
100
101       With --merge option, you could check out a merge commit:
102
103
104
105           $ git pr origin:755 --merge
106           remote: Enumerating objects: 3, done.
107           remote: Counting objects: 100% (3/3), done.
108           remote: Compressing objects: 100% (3/3), done.
109           remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
110           Unpacking objects: 100% (3/3), done.
111           From github.com:tj/git-extras
112           bf7dd69..de6e51c  refs/pull/755/merge -> pr/755
113           Switched to branch ´pr/775´
114
115           $ git log pr/775 --oneline
116           de6e51c (pr/755) Merge bf7dd6...
117
118
119
120       To clean up old branches:
121
122
123
124           $ git pr clean
125
126           Deleted branch pr/226 (was b96a8c2).
127           Deleted branch pr/220 (was d34dc0f).
128           Deleted branch pr/775 (was de6e51c).
129
130
131

AUTHOR

133       Originally from https://gist.github.com/gnarf/5406589
134

REPORTING BUGS

136       <https://github.com/tj/git-extras/issues>
137

SEE ALSO

139       <https://github.com/tj/git-extras>
140
141
142
143                                   June 2019                         GIT-PR(1)
Impressum