Search code examples
gitgit-submodules

How to fix "modified content, untracked content" in git?


The objective is to commit a git branch. The output of "git status" for the branch is:

On branch zeromq_new
Your branch is up to date with 'origin/zeromq'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)
  (commit or discard the untracked or modified content in submodules)

      modified:   log4cplus (modified content, untracked content)
      modified:   ../lib/notification/cppzmq (modified content)

The directory structure looks like this:

HySecureGateway
├──fes
│   └──log4cplus
│       ├──.git
│       ├──.gitattributes
│       ├──.gitignore
│       ├──.gitmodules
│       ├──catch
│       │   ├──.git
│       │   ├──.gitattributes
│       │   ├──.github
│       │   ├──.gitignore
│       │   └──.github
│       │       ├──issue_template.md
│       │       └──pull_request_template.md
│       └──threadpool
│           └──.github
└──lib
    └──notification
        └──cppzmq
            ├──.git
            └──.gitignore

I read an answer of to a similar question here:

How to track untracked content? ,

and couldn't understand it completely. Also the logc4plus/.gitmodules contains this:

[submodule "threadpool"]

        path = threadpool
        url = https://github.com/log4cplus/ThreadPool.git

[submodule "catch"]

        path = catch
        url = https://github.com/philsquared/Catch.git

Solution

  • What I did was to run:

    git rm -rf --cached myuntrackedfolder
    

    This tells git to forget about it (since it was being tracked formally).

    Then I used:

    git add myuntrackedfolder 
    

    to add it and I was good to go.