【问题标题】:Add files in "submodule" directories to Main Project将“子模块”目录中的文件添加到主项目
【发布时间】:2017-08-30 17:49:18
【问题描述】:

我正在向项目中添加文件夹...其中一些文件夹是 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)

【问题讨论】:

  • @marcusshep 简单看一下,问题没有 git 子文件夹,并且该问题想要合并历史......这绝对不是重复的。我只想在具有 .git 文件夹的文件夹中添加文件。没有子树/子模块魔法。没有历史合并。
  • 是的......这个问题绝不会形成或形成这个问题的副本。我不关心子模块的历史,也不想删除子文件夹 git 目录。我只是想将文件(不是 .git 目录)添加到主项目中,而不会弄乱子模块。

标签: git git-submodules


【解决方案1】:

列出所有 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"

为所有“子模块”将其包装在一个单行中。

Hackish,但适用于这个项目。

【讨论】:

    猜你喜欢
    • 2012-02-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-02-14
    • 1970-01-01
    • 2013-03-11
    相关资源
    最近更新 更多