【发布时间】:2012-07-31 13:49:42
【问题描述】:
我的主分支具有以下目录结构
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 分支拥有原始 master templates/ 所拥有的一切。是否可以告诉 git 仅将某些文件和文件夹保留在 master 分支中,或者此逻辑是否在 git 级别上硬编码,即在子目录合并期间,它使用指向 templates/ 的树状结构,并且 templates/ 中的所有内容都是并且只能是子目录模板/?
【问题讨论】:
-
是的,很遗憾,cherry-pick 不是一个解决方案。我正在尝试构建一个自动化系统,它将进行主模板更改,将这些更改移动到单独的“主模板”分支,然后主模板将合并到主题分支中:templates_theme1、templates_theme2 等。问题是产品的方式是结构化的——templates/ 文件夹下的一些东西与模板无关,也不需要进入那些最终的 templates_theme1 分支。
标签: git git-merge git-subtree