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