1GIT-PR(1) Git Extras GIT-PR(1)
2
3
4
6 git-pr - Checks out a pull request locally
7
9 git-pr [-m|--merge] <number> [<remote>]
10 git-pr [-m|--merge] <[remote]:number>...
11 git-pr [-m|--merge] <url>...
12 git-pr clean
13
15 Creates a local branch based on a GitHub pull request number or URL,
16 and switch to that branch afterwards.
17
19 <remote>
20
21 The name of the remote to fetch from. Defaults to origin.
22
23 <url>
24
25 GitHub pull request URL in the format
26 https://github.com/tj/git-extras/pull/453.
27
28 -m | --merge
29
30 Checkout a merge commit against the branch the pull request is target‐
31 ing. Because this feature uses a private API with which GitHub checks
32 the pull request´s mergeability, it only works with the opened pull
33 request. If the merge commit is not up-to-date, please visit the pull
34 request web page to trigger the rebuild.
35
37 This checks out the pull request 226 from origin:
38
39
40
41 $ git pr 226
42
43 remote: Counting objects: 12, done.
44 remote: Compressing objects: 100% (9/9), done.
45 remote: Total 12 (delta 3), reused 9 (delta 3)
46 Unpacking objects: 100% (12/12), done.
47 From https://github.com/tj/git-extras
48 * [new ref] refs/pull/226/head -> pr/226
49
50 Switched to branch ´pr/226´
51
52
53
54 This pulls from a different remote:
55
56
57
58 $ git pr 226 upstream
59
60
61
62 This does the same thing as the command above:
63
64
65
66 $ git pr upstream:226
67
68
69
70 You can also checkout a pull request based on a GitHub URL:
71
72
73
74 $ git pr https://github.com/tj/git-extras/pull/453
75
76 From https://github.com/tj/git-extras
77 * [new ref] refs/pull/453/head -> pr/453
78 Switched to branch ´pr/453´
79
80
81
82 You could even pull multiple pull requests via the GitHub URL or the ID
83 with remote specified:
84
85
86
87 $ git pr upstream:226 upstream:443
88 $ git pr upstream:443 https://github.com/tj/git-extras/pull/453
89
90
91
92 Note that git pr PR-A PR-B is equal to:
93
94
95
96 $ git pr PR-A
97 $ git pr PR-B
98
99
100
101 Therefore, if one of the pull request is failed to pull, this command
102 will still go ahead and pull the others. The final exit code will be
103 decided by the result of the final pulling.
104
105 With --merge option, you could check out a merge commit:
106
107
108
109 $ git pr origin:755 --merge
110 remote: Enumerating objects: 3, done.
111 remote: Counting objects: 100% (3/3), done.
112 remote: Compressing objects: 100% (3/3), done.
113 remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
114 Unpacking objects: 100% (3/3), done.
115 From github.com:tj/git-extras
116 bf7dd69..de6e51c refs/pull/755/merge -> pr/755
117 Switched to branch ´pr/775´
118
119 $ git log pr/775 --oneline
120 de6e51c (pr/755) Merge bf7dd6...
121
122
123
124 To clean up old branches:
125
126
127
128 $ git pr clean
129
130 Deleted branch pr/226 (was b96a8c2).
131 Deleted branch pr/220 (was d34dc0f).
132 Deleted branch pr/775 (was de6e51c).
133
134
135
137 Originally from https://gist.github.com/gnarf/5406589
138
140 <https://github.com/tj/git-extras/issues>
141
143 <https://github.com/tj/git-extras>
144
145
146
147 September 2020 GIT-PR(1)