首页 > 解决方案 > 如何从另一个仓库移动多个目录并保留 git log 目录行为?

问题描述

我已经阅读了几个关于在 git 存储库之间移动目录的主题,我决定使用的是这个,它使用git subtree.

按照步骤,一切似乎都运行良好,但问题到了最后。

我留下了一个新的存储库,我想移动的目录的所有内容都在根目录中。如果我将 agit mv内容放入我想要的子目录,当我做 a 时git log -- sub\dir\1,从那里看不到历史记录。历史仅从根可见。

我计划以这种方式移动多个目录,所以它会有点影响,因为现在我必须git log --follow在我查找历史记录的每个文件上使用。

有没有其他方法,或者我做错了什么,以便我可以将历史保存在正确的子目录下?如果有帮助,我在新仓库中想要的文件夹结构实际上与旧仓库中的文件夹结构相同(嗯,至少在git subtree命令之前)。

明确地说,这是我开始的内容:

\old-repo
   \sub\dir\1
   \sub\dir\2
   \sub\dir\3

这是我现在的位置:

\new-repo (subdir1 history viewable from here)
   \sub\dir\1 (subdir1 history is NOT viewable, besides the most recent git mv)

这是我真正想要的:

\new-repo
   \sub\dir\1 (subdir1 history viewable from here)
   \sub\dir\2 (subdir2 history viewable from here)
   \sub\dir\3 (subdir3 history viewable from here)

标签: gitgit-loggit-subtreegit-mv

解决方案


推荐阅读