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

GitGit Submodules

Git Problem Overview


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:

https://stackoverflow.com/questions/4161022/how-to-track-untracked-content?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa ,

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

Git Solutions


Solution 1 - Git

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.

Solution 2 - Git

Remove .git from subfolders. This works for me.

Solution 3 - Git

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.

Solution 4 - Git

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)

Solution 5 - Git

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

Solution 6 - Git

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!!!

Solution 7 - Git

log4cplus is your submodule that has modified and untracked contents.

  • modified content: Go to your submodule "log4cplus" commit your modified changes
  • untracked contents: Says that you have added new files or new folders in your submodule that you have not yet started to track i.e., git add . In case you want to ignore the untracked files add them to the .gitignore.

Now you should be able to update the commits from the submodule onto your main or outer repository. Please note that deleting the .git file in your submodule is not a solution.

Solution 8 - Git

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.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionAyushView Question on Stackoverflow
Solution 1 - Gitxplorer1View Answer on Stackoverflow
Solution 2 - GitBishwa TimilsinaView Answer on Stackoverflow
Solution 3 - GitQuan TruongView Answer on Stackoverflow
Solution 4 - GitTaigerView Answer on Stackoverflow
Solution 5 - GitKele HuangView Answer on Stackoverflow
Solution 6 - GitMeghesh ShenoyView Answer on Stackoverflow
Solution 7 - Gitvivek87799View Answer on Stackoverflow
Solution 8 - GitSara BenloulouView Answer on Stackoverflow