Skip to content

Commit cf3ef63

Browse files
committed
docs: add "If you sent to the wrong branch"
1 parent 00c6596 commit cf3ef63

1 file changed

Lines changed: 48 additions & 0 deletions

File tree

contributing/workflow.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,54 @@ And finally push your local branch to your GitHub repository:
276276
> git push --force-with-lease origin fix/problem123
277277
```
278278

279+
## If you sent to the wrong branch
280+
281+
If you have sent a PR to the wrong branch, you need to create a new PR branch.
282+
283+
When you have the PR branch `feat-abc` and you should have sent the PR to `4.3`,
284+
but you created the PR branch from `develop` and sent a PR.
285+
286+
Update your `4.3` branch:
287+
288+
```console
289+
> git switch 4.3
290+
> git fetch upstream
291+
> git merge upstream/4.3
292+
> git push origin 4.3
293+
```
294+
295+
Create a new branch `feat-ab.new` from the correct branch `4.3`:
296+
297+
```console
298+
> git switch -c feat-abc.new 4.3
299+
```
300+
301+
Cherry-pick the commits you did:
302+
303+
```console
304+
> git cherry-pick <commit_id> <commit_id> <commit_id> ...
305+
```
306+
307+
Rename the PR branch `feat-abc`:
308+
309+
```console
310+
> git branch -m feat-abc feat-abc.old
311+
```
312+
313+
Rename the new branch `feat-abc.new` to `feat-abc`.
314+
315+
```console
316+
> git branch -m feat-abc.new feat-abc
317+
```
318+
319+
Force push.
320+
321+
```console
322+
> git push --force-with-lease origin feat-abc
323+
```
324+
325+
On the GitHub PR page, change the base branch to the correct branch `4.3`.
326+
279327
## Cleanup
280328

281329
If your PR is accepted and merged into the shared repository, you can

0 commit comments

Comments
 (0)