Skip to content

Commit 57d7fd4

Browse files
committed
auto sync #3
1 parent b4e58ff commit 57d7fd4

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

.github/workflows/sync.yml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,21 +68,20 @@ jobs:
6868
git fetch upstream ${{ inputs.upstream_sync_branch }}:temp_${{ inputs.upstream_sync_branch }}
6969
# 基于临时分支创建新的本地分支
7070
git checkout -b ${{ inputs.target_sync_branch }} temp_${{ inputs.upstream_sync_branch }}
71-
# 删除临时分支
72-
git branch -d temp_${{ inputs.upstream_sync_branch }}
71+
# 强制删除临时分支,没必要
72+
# git branch -D temp_${{ inputs.upstream_sync_branch }}
7373
# 推送新分支到远程仓库
7474
git push origin ${{ inputs.target_sync_branch }}
7575
else
7676
echo "branch_exists=true" >> $GITHUB_OUTPUT
7777
echo "Remote branch ${{ inputs.target_sync_branch }} exists."
7878
# 创建一个临时分支来fetch远程分支的内容
7979
git fetch upstream ${{ inputs.upstream_sync_branch }}:temp_${{ inputs.upstream_sync_branch }}
80-
# 这里使用了 git branch -f 来强制更新 target_sync_branch 分支的指向,然后切换到该分支。这将会丢弃 target_sync_branch 分支上所有未合并的更改。
81-
git branch -D ${{ inputs.target_sync_branch }} # 强制删除本地分支
82-
git branch -f ${{ inputs.target_sync_branch }} temp_${{ inputs.upstream_sync_branch }}
83-
git checkout ${{ inputs.target_sync_branch }}
84-
# 删除临时分支
85-
git branch -d temp_${{ inputs.upstream_sync_branch }}
80+
ggit checkout ${{ inputs.target_sync_branch }}
81+
# 合并,使用传入解决合并冲突
82+
git merge --strategy-option theirs temp_${{ inputs.upstream_sync_branch }}
83+
# 强制删除临时分支,没必要
84+
# git branch -D temp_${{ inputs.upstream_sync_branch }}
8685
# 推送新分支到远程仓库
8786
git push origin ${{ inputs.target_sync_branch }}
8887
fi

0 commit comments

Comments
 (0)