Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【Git】从一个分支cherry-pick多个commit到其他分支 #104

Open
xszi opened this issue Feb 27, 2023 · 0 comments
Open

【Git】从一个分支cherry-pick多个commit到其他分支 #104

xszi opened this issue Feb 27, 2023 · 0 comments

Comments

@xszi
Copy link
Owner

xszi commented Feb 27, 2023

在branch1开发,进行多个提交,这时切换到branch2,想把之前branch1分支提交的commit都【复制】过来,怎么办?

首先切换到branch1分支,然后查看提交历史记录,git log

例如我的git log 如下:

commit1 xxx_id1
commit2 xxx_id2
commit3 xxx_id3

我想把 commit1 和 commit3 复制到 branch2 分支里,只需要切换到 branch2 分支,然后执行

git cherry-pick xxx_id1…xxx_id3

注意中间的两个点,表示把两个commit区间的所有commit都复制过去

单个 commit 只需要 git cherry-pick commitid

多个commit 只需要git cherry-pick commitid1…commitid100

注意,不包含第一个 commitid , 即 git cherry-pick (commitid1…commitid100]

如果想搞成[]区间,使用 git cherry-pick A^…B 相当于[A B]包含A

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant