将目录从一个Git仓库迁移到另一个具有ALL历史记录的目录

时间:2012-12-13 16:18:47

标签: git

我有一些文件存在于Repo 1的目录中。假设它是一个视频播放功能。未在此目录中创建与此功能相关的所有文件。有时开发人员会意识到这种共性,并将所有文件移动到一个公共位置。

现在我们有一个核心库,我们希望所有这些文件都能存在,以便其他项目可以重用它们。我已成功使用以下命令将文件放入另一个存储库,但在将它们在Repo 1中移动到公共目录之前,它缺少文件的历史记录。

我怎样才能这样做,使文件的整个历史记录都包含在核心库中,而不管它在Repo 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

1 个答案:

答案 0 :(得分:0)