File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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
281329If your PR is accepted and merged into the shared repository, you can
You can’t perform that action at this time.
0 commit comments