0

I'm adding folders to a project... Some of these folders are git projects.

Generally speaking, I should be adding "submodules"... but, for this project, I want to ignore the fact that these folders are submodules.

How do you just add the files even though they are a "submodule"?

I just want to 'git add -A', commit "message" and push. I want to keep the .git folders - and not add/commit the .git folders - and effectively ignore the "submodule" portion.

Folder:

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)
WernerCD
  • 2,137
  • 6
  • 31
  • 51
  • Possible duplicate of [How to import existing Git repository into another?](https://stackoverflow.com/questions/1683531/how-to-import-existing-git-repository-into-another) – marcusshep Aug 30 '17 at 17:55
  • @marcusshep a brief look shows that question doesn't have git subfolders and that question wants to merge histories... this is definitely not a duplicate. I just want to add files in folders that have a .git folder. No subtree/submodule magic. No history merging. – WernerCD Aug 30 '17 at 17:59
  • Yeah... that question is in no way shape or form a duplicate of this. I don't care about the submodule histories and I don't want to remove the subfolder git directories. I simply want to add the files (not .git directories) to the main project without messing with submodules. – WernerCD Aug 30 '17 at 18:04

1 Answers1

0

List all git submodules (one of many answers here)

git ls-files --stage | grep 160000

result

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

remove cached entry

git rm --cached web/libraries/randomLibrary

then add all files in that folder

 git add web/libraries/randomLibrary/*

then add all

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

Wrapped this up in a one-liner for all "submodules".

Hackish, but works for this project.

WernerCD
  • 2,137
  • 6
  • 31
  • 51