2017-08-30 33 views
0

我將文件夾添加到項目中...其中一些文件夾是git項目。將「子模塊」目錄中的文件添加到主項目中

一般來說,我應該添加「子模塊」...但是,對於這個項目,我想忽略這些文件夾是子模塊的事實。

即使它們是「子模塊」,您如何添加文件?

我只想'git add -A',提交「消息」並推送。我想保留.git文件夾 - 而不是添加/提交.git文件夾 - 並有效地忽略「子模塊」部分。

文件夾:

YYY 
|- .git <-- Project .git 
|- ZZZ <-- Project ZZZ 
     |- .git <-- Don't add this 
     |- (project files) <-- do add these 
|- QQQ <-- just another folder with.. 
     |- MMM <-- Project MMM inside 
      |- .git <-- Don't add this 
      |- (project files) <-- do add these 
|- (project files) 
+0

[如何將現有的Git存儲庫導入到另一個?](https://stackoverflow.com/questions/1683531/how-to-import-existing-git-repository-into-another) – marcusshep

+0

@marcusshep a簡短的看看錶明,問題沒有git子文件夾,並且該問題想要合併歷史記錄......這絕對不是重複的。我只想添加具有.git文件夾的文件夾。沒有子樹/子模塊的魔力。沒有歷史合併。 – WernerCD

+0

是的......這個問題決不會形成或重複這個問題。我不在乎子模塊的歷史,我不想刪除子文件夾git目錄。我只是想將文件(不是.git目錄)添加到主項目中,而不會與子模塊混淆。 – WernerCD

回答

0

列出所有的git子模塊(很多答案的一個here

git ls-files --stage | grep 160000 

結果

160000 fdd0df41eb6271f06711c791af587c614097eedb 0  web/libraries/randomLibrary 
.... 

刪除緩存項

git rm --cached web/libraries/randomLibrary 

然後添加的所有文件文件夾

git add web/libraries/randomLibrary/* 

中再加入所有

git add --all && git commit -m "Message" 

這裹起來一個班輪所有「子模塊」。

黑客,但適用於此項目。

相關問題