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.  Because  this feature uses a private API with which GitHub checks
31       the pull request´s mergeability, it only works  with  the  opened  pull
32       request.  If  the merge commit is not up-to-date, please visit the pull
33       request web page to trigger the rebuild.
34

EXAMPLES

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

AUTHOR

136       Originally from https://gist.github.com/gnarf/5406589
137

REPORTING BUGS

139       <https://github.com/tj/git-extras/issues>
140

SEE ALSO

142       <https://github.com/tj/git-extras>
143
144
145
146                                  August 2019                        GIT-PR(1)
Impressum