[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:
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:
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
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.
Remove .git from subfolders. This works for me.
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.
- Remove .git/ from log4cplus and ../lib/notification/cppzmq.
- 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
- Add and commit the directories to your branch again.
- Push to your branch.
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)
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!!!
I also encountered such a problem, and it indeed bothered me a lot.
I solved it by running
git submodule update.
I have closed the editor (Visual Studio) and I typed the usual commands:
git add .
git commit -m "Comment text"
git push -u origin master
This worked for me.