[英]Merging changes to a folder from another repository
We have a git repository ProjA
with a plugin stored in /plugins/foo
. 我们有一个git仓库
ProjA
,其插件存储在/plugins/foo
。 After this project was completed, a second repository ProjB
was started. 该项目完成后,启动了第二个存储库
ProjB
。 Somewhere along the line foo was added to the repo like so 沿着foo的某处像这样添加到了仓库中
cp ../ProjA/plugins/foo plugins/foo
git add .
git commit -m "Added Foo Plugin"
followed immediately by 随后立即
git mv plugins/foo plugins/foobar
git commit -m "Fixed naming conflict with Foo"
Then a bunch of work was done. 然后完成了很多工作。
How do I merge all the changes (and more importantly history) to ProjB/plugins/foobar
into ProjA/plugins/foo
without any of the other changes in ProjB/
? 如何
ProjB/plugins/foobar
所有更改(更重要的是历史记录)合并到ProjA/plugins/foo
而在ProjB/
没有其他任何更改?
I've tried creating a subtree and merge it in but all the changes were in /
and there were no common ancestors to merge with. 我尝试创建一个子树并将其合并,但是所有更改都在
/
并且没有可合并的共同祖先。
Then I tried using git format-patch
but I couldn't work out how to make it only apply to a subdirectory. 然后我尝试使用
git format-patch
但无法弄清楚如何使其仅适用于子目录。
My best guess is to somehow combine the two actions but I don't know how to deal with the paths. 我最好的猜测是以某种方式将这两个动作结合起来,但是我不知道如何处理路径。
I managed to sort out the paths using --src-prefix
and --dst-prefix
on git format-patch
. 我设法在
git format-patch
上使用--src-prefix
和--dst-prefix
来整理路径。
There were a few problems involving merges that I had to sort out manually during the 200+ commits imported, but other than that it seems to have worked. 在导入200多次以上的提交期间,我不得不手动解决一些涉及合并的问题,但除此之外似乎还行得通。
My end workflow was something like this: 我的最终工作流程是这样的:
cd ProjB
git subtree split --prefix=plugins --branch=plugins-only
mkdir ../ProjBPlugins
cd ../ProjBPlugins
git init .
git pull ../ProjB plugins-only
git format-patch --stdout --src-prefix=a/plugins/ --dst-prefix=b/plugins/ e2f0732f92078a83fd210d415b659b41817a865f > foo.patch
cp foo.patch ../ProjA/
cd ../ProjA
git am foo.patch
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.