保留子目录的git日志,而不是子模块

时间:2015-06-01 19:25:33

标签: git github

我在一个github存储库中有两个app目录,它们有单独的git日志。

$ git rm --cached store_app
rm 'store_app'
$ git rm --cached blog_app
fatal: not removing 'blog_app' recursively without -r

我对这两个目录只做了不同的事情,一个是我在超级目录git commit之前git init,另一个之后。{ (两个子目录都没有远程)

094-active_resource-basics/store_app$ git commit -m "commit before" # after init and add
094-active_resource-basics$ git init
094-active_resource-basics/blog_app$ git commit -m "commit after"  # after init and add
094-active_resource-basics$ git push # after add and commit

只有“blog_app”目录按预期工作。我想保留store_app目录的git日志。这不应该是“子项目”

1 个答案:

答案 0 :(得分:0)

在根目录git init之后,它不是子模块。 store_app目录在此处保留子模块:

$ git rm --cached store_app   # index file name
$ git add store_app           # directory name

但不在这里(忽略子目录提交):

$ git rm --cached store_app
$ git init
$ git add store_app

这对我很有意思,因为当你将repo作为子目录移动到另一个repo时,repo会成为子模块。 (没有.gitmodules)但是您不能通过在子目录中提交将子目录创建到子项目中。 (当然你会做git submodule add)我不确定用例如果它是一个子项目并且没有.gitmodules文件(只有索引文件)同时以任何方式。

相关问题