svn合并git上游

A是git, B基于A开发, B使用svn, 如何合并A后面的小修改(比如release分支上的修复)?

下面是个大致的做法:

git svn clone B
cd B
git add remote A
git fetch A # 不需要checkout

# 获取某个范围内的commit, 并把顺序反过来, 因为git log把最新的放在最上面, 需要反一下; 放到一个文件中
git log REL7_3_12..REL7_3_13 --oneline | awk '{print $1}' | tac > 7.3.13.commits

# 先确认在正确的分支, 目标分支
# for each commit in 7.3.13.commits
git cherry-pick -x 660fcf0f67

# 可以把一大堆cherry-pick写在脚本中, 前面加上set -e, 出错手动修复, 已pick的删掉, 继续执行脚本pick
set -e
git cherry-pick -x 430f110f88
git cherry-pick -x 280fcf8867
git cherry-pick -x 770f880f69
...

git cherry-pick --help:

-x
When recording the commit, append a line that says "(cherry picked from commit ...)" to the original
commit message in order to indicate which commit this change was cherry-picked from. This is done only
for cherry picks without conflicts. Do not use this option if you are cherry-picking from your private
branch because the information is useless to the recipient. If on the other hand you are
cherry-picking between two publicly visible branches (e.g. backporting a fix to a maintenance branch
for an older release from a development branch), adding this information can be useful.

posted on 2023-07-04 07:25  Gao科技  阅读(37)  评论(0)    收藏  举报