我一直在使用 git-p4 将 Perforce 存储库的部分内容克隆到 git 存储库中。我检查的树具有以下 Perforce“分支”结构:
回购/发布
回购/发布B
仓库/功能
仓库/功能B
我的本地 git 存储库中有一堆 git 提交到 featureA 目录;但是,我想将这些提交“rebase”到 featureB 目录中。有没有办法将最初应用于一个目录的一组补丁/提交转换到另一个目录上?
是的。如果你的提交影响only repo/featureA
这会很容易:
mkdir patches
git format-patch -o patches master..my_featureA_branch
git am patches/* -p3 --directory=repo/featureB
你就完成了。
如果您的提交更改了 repo/featureA 之外的文件,您需要将其删除,
cat >mystuff.sed <<\EOD
/^(From [0-9a-f]{40}|diff --git )/!{H;$!d}
x
/^From /b
${h;s,.*--,--,;x}
\,^diff[^\n]* [ab]/repo/featureA/,!{$!d;x;b}
${p;x}
EOD
and
sed -s -i -r -f mystuff.sed patches/*
之前git am
。任何完全不影响任何内容的补丁repo/featureA
你必须git am --skip
在这种情况下。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)