[英]How can I start a new branch with squashed commits from an open PR?
The problem: I have a PR with a tonne of commits.问题:我有一个提交大量提交的 PR。 The branch name is also not accurate.
分支名称也不准确。 I would like to start a new branch, and continue from the latest commit, without cherry picking each commit.
我想开始一个新的分支,并从最新的提交继续,而不是挑选每个提交。 I want all the work to be reduced to 1 commit that reflects its latest state.
我希望将所有工作减少到 1 次提交,以反映其最新的 state。
I first tried rebasing, but the commits conflict with each other.我第一次尝试变基,但提交相互冲突。
I then thought about cherry picking just the latest commit but I'm unsure of the syntax.然后我考虑只挑选最新的提交,但我不确定语法。 (yes i read the docs but its not clear to me still).
(是的,我阅读了文档,但我仍然不清楚)。
I have checked out a new branch:我检查了一个新分支:
git checkout -b <new-branch>
then I tried:然后我尝试了:
git cherry pick <commit-sha> <branch-name>
The branch I want to 'correct' is an open PR.我想“纠正”的分支是一个开放的 PR。
This doesn't work as the terminal says "Unknown commit pick".这不起作用,因为终端显示“未知提交选择”。
Can anyone help me out?谁能帮我吗?
I have a PR with a tonne of commits.
我有一个有大量提交的 PR。 The branch name is also not accurate.
分支名称也不准确。 I would like to start a new branch, and continue from the latest commit, without cherry picking each commit.
我想开始一个新的分支,并从最新的提交继续,而不是挑选每个提交。 I want all the work to be reduced to 1 commit that reflects its latest state.
我希望将所有工作减少到 1 次提交,以反映其最新的 state。
Checkout your old branch.检查你的旧分支。
Make a new branch and get on to it.创建一个新分支并继续它。
reset --soft
to the first commit of the old branch (possibly even the commit that you branched "from") and make a commit. reset --soft
为旧分支的第一次提交(甚至可能是您“从”分支的提交)并进行提交。
Now your new branch "consists" of just that one commit, embodying the whole history of the old branch.现在,您的新分支“仅包含”一个提交,体现了旧分支的全部历史。 Keep working.
继续工作。 (You can withdraw the PR and delete the old branch if you like.)
(如果您愿意,可以撤回 PR 并删除旧分支。)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.