我有一个git repo,我想为它添加一个子模块.问题是,子模块作为另一个仓库内的文件夹存在.我可以只将该文件夹添加为子模块吗?
首先 - 向这个问题道歉.关于它的话题已经很多了.但我对他们没有太多运气.我对git缺乏熟悉并没有多大帮助.
我正在将一个文件夹从一个git repo移动到另一个(已经存在).例如
repo-1
---- dir1
---- dir2
---- dir3
---- dir-to-move
---- dir5
repo-2
---- dir1
---- dir2
---- dir3
Run Code Online (Sandbox Code Playgroud)
最后我希望回购看起来像
repo-1
---- dir1
---- dir2
---- dir3
---- dir-to-move
---- dir5
repo-2
---- dir1
---- dir2
---- dir3
---- dir-to-move
Run Code Online (Sandbox Code Playgroud)
也就是说,在两个回购中都存在dir-to-move.但最终我会将最新的更改迁移到repo-2并从repo-1中移除dir-to-move.
我最初的研究让我相信我需要使用filter-branch.例如
如何使用`git format-patch`和`git am`将文件从一个git repo移动到另一个保存历史记录
我已经知道子树取代了这种方法.然而,它并没有达到我的预期.我以为我能够做类似的事情
在repo-1工作区中
git subtree split -P dir-to-move -b split
Run Code Online (Sandbox Code Playgroud)
将拆分分支过滤到仅dir-to-move及其历史记录.然后在repo-2工作区 …