克隆具有子模块的repo时如何保持干净的历史记录?

时间:2017-05-28 15:41:49

标签: git

我有一个repo A,它是一个包含子模块的模板项目。我希望能够克隆此存储库并使用此模板项目启动一个新项目。

此命令有效,但它为我提供了一个初始化的存储库,其中包含了repo A的最新提交。

git clone --recursive <url>

我更喜欢克隆repo,然后使用自定义相关消息(例如“init from template project”)作为第一次提交,而不是最新的子模块提交消息。

This answer我应该这样做(我添加了--recursive来克隆子模块):

git clone --recursive --depth=1 --branch=master git://someserver/somerepo dirformynewrepo
rm -rf !$/.git

之后我尝试了:

git init
git submodule init
git commit -m "init from template"
git push

每个子模块文件都不会被识别为子模块,并作为普通文件提交。我怎么能避免这种情况?

1 个答案:

答案 0 :(得分:0)

A

git commit --allow-empty  -m 'init from template project'

启动没有历史记录的新分支。如果您仍想要历史记录,只需使用

创建提交
git commit --amend -m 'init from template project'

你也可以用

重写顶部
languages.find(c)
相关问题