首页 > 解决方案 > git subtree 命令将文件添加到父树

问题描述

我运行了这个命令:

git subtree add --prefix=config --squash git@github.com:user/repo.git master

在根文件夹中,我提交了更改并推送到远程。配置文件夹中的子树文件已包含在内。

我应该 .gitignore 配置目录吗?为什么它在父 git repo 中包含子树文件?

标签: gitgit-subtree

解决方案


我应该.gitignore配置目录吗?

不。

为什么它在父 git repo 中包含子树文件?

因为那不是子模块(仅在父级记录子存储库的 SHA1)。
那是一个子树在此处介绍),它确实将一个 repo 包含到另一个 repo 中。

https://3kllhk1ibq34qk6sp3bhtox1-wpengine.netdna-ssl.com/wp-content/uploads/BeforeAfterGitSubtreeDiagram.png


推荐阅读