Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get rid of Git submodules untracked status?

People also ask

How do I fix modified content untracked content?

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

How do I track untracked files in git?

You have to add the untracked files of the repository by using the “git add” command and run the “git stash” command to save the untracked file and clean the current directory for working by removing the untracked file from the repository folder.


I found this blog post to work overall. By adding the ignore = dirty option to each one of the entries in the .gitmodules file.

[submodule "zen-coding-gedit3"]
    path = zen-coding-gedit3
    url = git://github.com/leafac/zen-coding-gedit3.git
    ignore = dirty

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 commit the untracked contents,
  • or reference the 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
    
  • or add a global .gitignore file (often ~/.gitignore-global). Like for example .DS_Store or in my case Carthage/Build as reported by Marián Černý in the comments. See .gitginore man page:

Patterns which a user wants Git to ignore in all situations (e.g., backup or temporary files generated by the user’s editor of choice) generally go into a file specified by core.excludesFile in the user’s ~/.gitconfig. Its default value is $XDG_CONFIG_HOME/git/ignore. If $XDG_CONFIG_HOME is either not set or empty, $HOME/.config/git/ignore is used instead.


You can also go to each submodule dir and act as a separated git. For example:

cd my/project/submodule
git status

... /gets the list of modified files/

git add .  //to add all of them to commit into submodule
git commit -m "message to your submodule repo"

you can also update your remote submodule repo with

git submodule update

after all


This worked out just fine for me:

git update-index --skip-worktree <path>

If it doesn't work with the pathname, try the file name. Let me know if this worked for you too.


It could be due to the detached HEAD in your submodule branch. If this is the case, go into your submodule path (e.g.: ./bundle/snipmate), then rungit checkout master.


I got stuck on this issue yesterday, in a project which had close to 12 submodules.

git status was showing output.

# 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:   proj1 (untracked content)
#   modified:   proj1 (modified content, untracked content)
#   ...

To resolve the untracked content error, I had to remove the untracked files from all submodules (all were *.pyc, *.pyo files generated by python) using a .gitignore.

To resolve the other, I had to run git submodule update which updated each of the submodules.