2017-05-28 43 views
0

我有一個回購A,它是一個包含子模塊的模板項目。我希望能夠克隆這個存儲庫並使用此模板項目啓動一個新項目。如何在使用子模塊克隆repo時保持清晰的歷史記錄?

此命令的作用,但它給我最新的初始化的庫提交回購A的

git clone --recursive <url> 

我寧願克隆回購,然後用像「初始化從定製相關信息提交模板項目「作爲第一次提交,而不是最新的子模塊提交消息。

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 

文件不被識別爲beeing一個子模塊的每個子模塊,並作爲正常文件提交。我怎樣才能避免這種情況?

回答

0

一個

git checkout --orphan new-branch 
git commit -m 'init from template project' 

開始一個新的分支沒有歷史。當你仍然希望歷史,只需創建一個犯了

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

您還可以

git commit --amend -m 'init from template project' 
改寫頂部