简体   繁体   English

将目录从一个Git存储库迁移到具有所有历史记录的另一个目录

[英]Migrate a directory from one Git repo to another with ALL history

I have some files that exist in a directory in Repo 1. Let's say its a video playback feature. 我在仓库1的目录中有一些文件。我们说它是一种视频播放功能。 All the file relevant to this feature were not created in this directory. 与此目录有关的所有文件均未创建。 Sometimes developers will realize that commonality and move all the files into a common location. 有时,开发人员会意识到这种共同性,并将所有文件移到一个共同的位置。

Now we have a core library where we want all these files to live so they can be reused by other projects. 现在,我们有了一个核心库,我们希望所有这些文件都存在于其中,以便其他项目可以重用它们。 I have successfully used the following commands to get the files into the other repository but it is missing the history of the files before they were moved in Repo 1 to a common directory. 我已经成功使用以下命令将文件放入另一个存储库,但是在将文件在存储库1中移至公共目录之前,文件的历史记录丢失了。

How can I go about doing this such that the file's entire history would be included in the core library regardless of how many times it was git mv'd in Repo 1? 我怎样才能做到这一点,以使文件的整个历史记录都将包含在核心库中,而不管它在回购1中被git mv了多少次?

cp -R  repo-where-feature-exists/ video-filtered-repo
cd video-filtered-branch
git remote rm origin 
git filter-branch --subdirectory-filter src/main/resources/static/video-poc/js/video/ -- --all 
rm -rf src/
mkdir -p component-library/src/main/resources/components/video
git mv -k * component-library/src/main/resources/components/video/
git commit -m "Moving files from where they were in the original location into the core location"


Now go to core…
cd /software/dp/core
git remote add video-feature /software/dp/video-filtered-repo/
git pull video-feature integration

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从一个 Git 存储库迁移到另一个 Git 存储库? - How to migrate from one Git repo to another Git repo? Git 将文件从一个存储库移动到另一个存储库以获取历史记录 - Git moving files from one repo to another repo for history 将一个 git 存储库复制到另一个具有历史记录的存储库 - Copying one git repo to another repo with history 将Git Repo从一台服务器迁移到另一台服务器 - Migrate Git Repo from one server to another server 将子文件夹从一个 git repo 移动到另一个保留历史记录 - Moving subfolder from one git repo to another preserving history 将资产从一个仓库移到另一个仓库,git提交历史? - Moving Assets from one Repo to another, git commit history? 如何将文件及其所有提交历史记录迁移到git中的新仓库中? - How to migrate a file and all its commit history to a new repo in git? 将文件夹从一个存储库复制/移动到另一个存储库,同时保留 Git 中的历史记录 - Copy/Move a folder from one repo to another repo while preserving history in Git 如何将一个 repo 移动到另一个 repo 文件夹并保留 git 历史记录? - How to move one repo to another repo folder and keep git history? Git将所有提交从一个回购转移到另一个回购 - Git bringing all commits from one repo to another
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM