简体   繁体   English

合并来自另一个存储库的文件夹更改

[英]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.

相关问题 合并从CVS存储库到GIT存储库的更改 - Merging changes from CVS repository to a GIT repository 将公共存储库中的更改合并到私有构建中 - Merging changes from a public repository into a private build 合并来自git存储库外部的更改 - Merging in changes from outside a git repository git只合并从一个存储库到另一个存储库的最近更改,这是一个不相关的快照(不是克隆) - git merging only recent changes from one repository to another which is an unrelated snapshot (not a clone) GIT-从另一个数据库创建的新存储库-正在合并吗? - GIT - New repository created from another — merging? 将文件夹从存储库移动到另一个存储库 - Move a folder from a repository to another repository 将现有分支从一个存储库合并到新存储库的另一分支 - Merging an existing branch from one repository to another branch of a new repository 为什么从特定的 GitHub 存储库合并到本地 Git 存储库会导致本地存储库中发生未提交的更改? - Why does merging from a particular GitHub repository into a local Git repository result in uncommitted changes in the local repository? 将现有的Git存储库合并到另一个现有存储库中的自制文件夹中 - Merging existing Git repository into self made folder within another existing repository GitHub-将更改合并到与主文件夹不同的文件夹中 - GitHub - merging changes to a branch in different folder from master
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM