konzepz konzepz - 3 months ago 17
Git Question

How to get rid of Git submodules untracked status?

I can't seem to get rid of untracked content in Git's submodules. Running

git status
yields:


# On branch master
# Changes not staged for commit:
# (use "git add ..." to update what will be committed)
# (use "git checkout -- ..." to discard changes in working directory)
# (commit or discard the untracked or modified content in submodules)
#
# modified: bundle/snipmate (untracked content)
# modified: bundle/surround (untracked content)
# modified: bundle/trailing-whitespace (untracked content)
# modified: bundle/zencoding (untracked content)
#
no changes added to commit (use "git add" and/or "git commit -a")


Adding the
--ignore-submodules
parameter hides these messages; but I wonder if there's a way to get rid of this dirt in a more suitable, core-ish, manner.

Answer

Since the git status reports untracked content, the actual way to have a clean status would be to go into each one of those submodules and:

  • add and commits those untracked contents,
  • or reference those same untracked contents in a .gitignore specific to each module.
  • or you can add the same ignored content to the submodule's .git/info/exclude, as peci1 reports in the comments.
  • or add dirty to the submodule specification, as mentioned in ezraspectre's answer (upvoted).

    git config -f .gitmodules submodule.<path>.ignore untracked