-
Notifications
You must be signed in to change notification settings - Fork 1
/
cherry-pick-pr.html
117 lines (91 loc) · 2.07 KB
/
cherry-pick-pr.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Cherry pick a pull request</title>
<meta name="description" content="Creating another pull request from an already
merged one, but this time against a different branch">
<style>
:root {
--border-code: aliceblue;
}
body {
margin: 4em;
line-height: 1.5;
max-width: 40em;
}
@media (width < 34em) {
body {
margin: 1em;
}
}
@media (prefers-color-scheme: dark) {
:root {
--border-code: #484c4e;
}
body {
background-color: hsl(240, 12%, 16%);
color: hsl(200, 10%, 94%);
}
}
p, li {
margin-block: 2.25em;
}
h3 + p {
margin-block-start: 2.75em;
}
ol {
padding-inline-start: 2ch;
}
li {
padding-inline-start: 0.5ch;
}
pre {
padding: 2ch;
padding-inline: 2.5ch;
border: 1px solid var(--border-code);
overflow-x: auto;
}
li > pre {
margin-inline-start: -2.5ch;
}
:not(pre) > code {
padding: 0.5ch;
border: 1px solid var(--border-code);
}
</style>
</head>
<body>
<h3>Cherry pick a pull request</h3>
<p>
I don't know if this is the best way to do this, but here goes. Suppose we have
a pull request that has already been merged into <code>main</code>, and now we
want to open another pull request with the same set of commits, but this time we
want to open it against the <code>release</code> branch.
</p>
<ol>
<li>Find the sha of the merge commit.</li>
<li>
Switch to <code>release</code>, and create a new branch.
<pre><code>git checkout release
git checkout -b backport-foo
</code></pre>
</li>
<li>
Cherry pick using <code>-m 1</code>. Note that this'll create a single commit that
references the merge, this'll not cherry pick the individual commits. This
might not be what you want, but that was enough for my purpose.
<pre><code>git cherry-pick -m 1 <merge-commit-id>
</code></pre>
</li>
<li>
Open a pull request against release. You can do it from the GitHub's web UI,
or via their CLI.
<pre><code>git push -u origin HEAD
gh pr create --base release --fill --web
</code></pre>
</li>
</ol>
</body>
</html>