Table of contents
1. Usage scenarios
When we need to merge code from different branches, there are two situations.
1、合并所有代码(git merge)
2、合并部分代码(git cherry-pick)
2. Basic grammar
commit-hash is the record value of each submission, which can be viewed through git log origin/[branch]
Grammar 1
git cherry-pick [commit-hash] (合并单个提交)
git cherry-pick C
Grammar 2
git cherry-pick [commit-hash1] [commit-hash2](合并多个提交)
git cherry-pick C D
Grammar three
git cherry-pick [commit-hash1]..[commit-hash2]
Merge all commits in the range from commit-hash1 to commit-hash2, but this does not include commit-hash1
git cherry-pick B..D
Grammar 4
git cherry-pick [commit-hash1]^..[commit-hash2]
Merge all commits in the range from commit-hash1 to commit-hash2, including commit-hash1
git cherry-pick B^..D
3. GitDesk tool operation method
Requirement: Merge some commits of main into new-branch
第一步:进到main,选择需要合并的提交记录(可多选)
第二步:选择cherry-pick 2 commits...
第三步:选择new-branch,点击按钮进行合并
最后push到远程就行了