svn合并git上游

发布时间 2023-07-04 07:29:29作者: Gao科技

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

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.