我有具有以下目录结构的主分支
templates/something.lib
templates/libs/1.lib
而且我还有一个包含以下文件的 templates_master 分支(就在根目录中)
a.html
b.html
然后我去 master 并将模板加载到 master templates 文件夹中
git read-tree --prefix=templates/ -u templates_master
现在形成这个主结构
templates/something.lib
templates/libs/1.lib
templates/a.html
templates/b.html
然后我留在 master 并在 templates/a.html 中引入一些更改,并进行几次提交。现在我希望这个修改过的 templates/a.html 回到原来的分支。我切换到 templates_master 分支并运行此命令
git merge -s subtree master
然而,这个命令不仅将 master:templates/a.html 复制到 templates_master:a.html ,而且还复制那些 libs 文件,所以基本上现在我的 templates_master 分支拥有原始主模板/拥有的所有内容。是否可以告诉 git 仅将某些文件和文件夹保留在主分支中,或者此逻辑是否在 git 级别上硬编码,即在子目录合并期间,它使用指向模板 / 的树状结构 / 模板 / 中的所有内容是并且只能是子目录模板/?