Use of git cherry-pick in the command line
1. Now you need to apply some commits on branch A to branch B.
2. Switch to branch: B, execute the command: git cherry-pick fbf19e86. Error: Conflict (Content): merge Conflict in platform/app/services/themeservice.php . Error: could not apply fbf19e86f4… . as shown in Figure 1
Auto-merging platform/app/Services/ThemeService.php
CONFLICT (content): Merge conflict in platform/app/Services/ThemeService.php
error: could not apply fbf19e86f4... 安装 2.0 主题模式下的主题。对接 SaaS 中心完成。
hint: After resolving the conflicts, mark them with
hint: "git add/rm ", then run
hint: "git cherry-pick --continue".
hint: You can instead skip this commit with "git cherry-pick --skip".
hint: To abort and get back to the state before "git cherry-pick",
hint: run "git cherry-pick --abort".
PS E:\wwwroot\object> git cherry-pick --abort
3. The reason was found. The reason is that there are still some submissions before submitting ID FBF19E86, which should not be skipped. as shown in Figure 2
4. Execute the command: git cherry-pick –abort, after a code conflict, give up the merge and return to the way it was before the operation.
PS E:\wwwroot\object> git cherry-pick --abort
PS E:\wwwroot\object>
5. Execute the command: git cherry-pick 5b0afab6. No more errors. Because this commit is my next commit on branch B. as shown in Figure 3
PS E:\wwwroot\object> git cherry-pick 5b0afab6
Auto-merging platform/app/Services/ThemeService.php
[feature/theme-store-wangqiang-20220526 531899fd34] 获取 SaaS 主题配置,重新索引多维数组的重构
Date: Tue May 10 15:56:06 2022 +0800
1 file changed, 1 insertion(+), 1 deletion(-)
6. Execute step 5 in sequence according to the submission ID time sequence, because some commit IDs are consecutive submissions. as shown in Figure 4
7. You can use the following simple syntax. There is a conflict. After resolving the code conflict, the first step is to re-enter the modified file to the staging area (git add .), and the second step is to use the following command to let the cherry pick process continue to execute. I used the Vim editor (exit directly) during the period, which I edited in phpstorm. as shown in Figure 5
Auto-merging platform/app/Http/Controllers/API/StatisticsController.php
CONFLICT (content): Merge conflict in platform/app/Http/Controllers/API/StatisticsController.php
Auto-merging platform/app/Http/Kernel.php
当前主题中间件替换为:CurrentTheme
# Conflicts:
# platform/app/Http/Controllers/API/StatisticsController.php
#
# It looks like you may be committing a cherry-pick.
# If this is not correct, please run
# git update-ref -d CHERRY_PICK_HEAD
# and try again.
# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
#
# Date: Tue May 10 17:55:23 2022 +0800
#
# On branch feature/theme-store-wangqiang-20220526
# Your branch is ahead of 'origin/feature/theme-store-wangqiang-20220526' by 1 commit.
# (use "git push" to publish your local commits)
#
# Cherry-pick currently in progress.
#
# Changes to be committed:
# modified: platform/app/Http/Controllers/API/StatisticsController.php
# modified: platform/app/Http/Kernel.php
E:/wwwroot/object/.git/COMMIT_EDITMSG [unix] (18:56 26/05/2022) 2,0-1 Top
[feature/theme-store-wangqiang-20220526 9766f26582] 当前主题中间件替换为:CurrentTheme
Date: Tue May 10 17:55:23 2022 +0800
5 files changed, 109 insertions(+), 166 deletions(-)
delete mode 100644 platform/app/Http/Middleware/ConfigTheme.php
rewrite platform/app/Http/Middleware/CurrentTheme.php (78%)
Auto-merging platform/app/Services/ThemeService.php
[feature/theme-store-wangqiang-20220526 25cf0e2a8a] 安装主题,入库实现
8. View the submission log, in line with expectations. All selected commit IDs have been included in Branch B. as shown in Figure 6
9. If the prompt: the previous cherry-pick is now empty, possible due due due to conflict resolution. Then execute the command: git cherry-pick –skip.
PS E:\wwwroot\object> git cherry-pick --continue
The previous cherry-pick is now empty, possibly due to conflict resolution.
If you wish to commit it anyway, use:
git commit --allow-empty
Otherwise, please use 'git cherry-pick --skip'
On branch feature/theme-store-wangqiang-202205262
Your branch is up to date with 'origin/feature/theme-store-wangqiang-202205262'.
Cherry-pick currently in progress.
(run "git cherry-pick --continue" to continue)
(use "git cherry-pick --skip" to skip this patch)
(use "git cherry-pick --abort" to cancel the cherry-pick operation)
nothing to commit, working tree clean





