【发布时间】:2017-06-26 03:10:54
【问题描述】:
此问题与How to move files from one git repo to another (not a clone), preserving history 等有关 Detach (move) subdirectory into separate Git repository 但问题(或者至少是解决方案,我认为)是不同的。我有以下目录结构:
abc/
.git/
def/
file1.txt
file2.txt
xyz/
file3.txt
abc 目录是 git 存储库的根目录,例如 repo1。
我想要的是将file2.txt 放在不同的存储库中,repo2(本地并链接到远程)。但是,我不想将file2.txt 移出目录(如相关问题中所述)。所有其他文件和文件夹 (def, file1.txt, xyz/*) 必须保留在 repo1。
当我执行git commit 或git push 时,对file1.txt 的更改应该转到repo1,对file2.txt 的更改应该转到repo2。
作为一种解决方法,我可以在def 中创建一个附加目录并将file2.txt 移动到那里,如果这样更容易的话。但是,我不想将file2.txt 移出当前树。
file2.txt的历史不一定需要在这次搬家中保留。
【问题讨论】:
-
我所知道的最接近你想要的东西是使用一个包含
file2.txt的子模块。
标签: git repository-design