[Solved] 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:

?   ???log4cplus
?       ???.git
?       ???.gitattributes
?       ???.gitignore
?       ???.gitmodules
?       ???catch
?       ?   ???.git
?       ?   ???.gitattributes
?       ?   ???.github
?       ?   ???.gitignore
?       ?   ???.github
?       ?       ???issue_template.md
?       ?       ???pull_request_template.md
?       ???threadpool
?           ???.github

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
Enquirer: Ayush


Solution #1:

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.

Respondent: xplorer1

Solution #2:

Remove .git from subfolders. This works for me.

Respondent: Bishwa Timilsina

Solution #3:

Solution involves removing .git/ from the directories with the “modified content, untracked content” label, removing the –cached filed from those directories, and then running git add on those directories once again.

Step-by-step solution:

  1. Remove .git/ from log4cplus and ../lib/notification/cppzmq.
  2. From parent directory from where you initialized your git repository, run the command:
    git rm -rf --cached log4cplus/ && git rm -rf --cached ../lib/notifications/cppzmq
  3. Add and commit the directories to your branch again.
  4. Push to your branch.

Happy coding.

Respondent: QuantumQuan

Solution #4:

For some reason these separate repos have altered files. There are a couple ways to deal with it, depending what they actually are.

You can navigate into each repo and see what files are changed. Then you can commit, make a new branch, or get rid of the changes.

If these repos are seperate projects that you want to track but not mess with, you can make your parent repo simply ignore changes in these submodules with:

git update-index --assume-unchanged $DIRECTORY

(where $DIRECTORY is the submodule you want to ignore changes to)

Respondent: Taiger

Solution #5:

What happening here is that you are in your root Folder Folder and You want to push all your children to git repository.So a git file is created.And if you get a untraceable or untracked file error the reason is some on your childen directories also have a git repository with it.You can delete the git repository from the untracked or untraceable folder by command
—->rmdir -Force -Recurse .git
This command will delete the local git repo in your untracebale or untracked directory and once again go to your root folder and type the same command.
Reinitialize the git repo and its Done!!!

Respondent: Meghesh Shenoy

Solution #6:

I also encountered such a problem, and it indeed bothered me a lot.
I solved it by running git submodule update.

Respondent: Kele Huang

Solution #7:

I have closed the editor (Visual Studio) and I typed the usual commands:

  1. git add .
  2. git commit -m "Comment text"
  3. git push -u origin master

This worked for me.

Respondent: Sara Benloulou

The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .

Leave a Reply

Your email address will not be published.