This status appears when a Git submodule contains new files that are not tracked by Git. Fix it by adding files to .gitignore, cleaning the submodule, or configuring Git to ignore untracked content in submodules.
When you run `git status` and see "untracked content" next to a submodule, Git is telling you that the submodule's working directory contains files that are not being tracked by Git. These are typically build artifacts, compiled files, temporary files, or newly created files that haven't been staged yet. Git treats submodules specially because they are nested repositories. When you run `git status` in the parent repository, Git checks the state of each submodule and reports whether it has: - **Untracked content**: New files not added to version control - **Modified content**: Changes to tracked files - **New commits**: The submodule HEAD differs from what the parent expects The "untracked content" status is often seen in projects that use submodules for dependencies or shared libraries. For example, when a submodule generates `.pyc` files, `node_modules`, build outputs, or IDE configuration files, these will cause the "untracked content" warning. While this status doesn't prevent you from committing changes to the parent repository, it can clutter your `git status` output and make it harder to see actual changes that need attention.
First, find out which files are causing the "untracked content" status:
cd path/to/submodule
git statusOr from the parent repository:
git diff --submoduleThis will show you the specific files that Git considers untracked within the submodule.
If you want Git to ignore untracked files in this submodule (the most common solution), add the ignore = untracked option to your .gitmodules file:
git config -f .gitmodules submodule.<path>.ignore untrackedFor example, if your submodule is at vendor/library:
git config -f .gitmodules submodule.vendor/library.ignore untrackedOr manually edit .gitmodules:
[submodule "vendor/library"]
path = vendor/library
url = https://github.com/example/library.git
ignore = untrackedThen commit the change:
git add .gitmodules
git commit -m "Ignore untracked content in submodule"If you want to ignore both untracked and modified content in submodules (only show commit differences), use ignore = dirty:
git config -f .gitmodules submodule.<path>.ignore dirtyAvailable ignore options:
- none (default): Show all changes (untracked, modified, commits)
- untracked: Hide untracked files, show modified files and commits
- dirty: Hide all working tree changes, only show commit differences
- all: Ignore all changes (the submodule is invisible to status/diff)
Note: Using dirty or all can hide important changes, so use with caution.
If the untracked files should be permanently ignored in the submodule, add them to the submodule's .gitignore:
cd path/to/submodule
echo "*.pyc" >> .gitignore
echo "__pycache__/" >> .gitignore
echo "node_modules/" >> .gitignoreIf you don't want to modify the submodule's tracked .gitignore, you can use the local exclude file instead:
echo "*.log" >> .git/modules/path/to/submodule/info/excludeThe exclude file works like .gitignore but is not part of the repository.
If the untracked files are not needed and you want to remove them:
cd path/to/submodule
git clean -fdTo clean all submodules at once from the parent repository:
git submodule foreach git clean -fdWarning: git clean -fd permanently deletes untracked files and directories. Use git clean -fdn first for a dry run to see what would be deleted.
If you want to completely reset submodules to match the parent repository's expectations:
git submodule update --force --recursiveThis will checkout the exact commit recorded in the parent repository, discarding local changes.
To also clean untracked files:
git submodule foreach --recursive git clean -fd
git submodule update --force --recursiveIf you just want to temporarily hide submodule changes without modifying configuration:
# Ignore only untracked content
git status --ignore-submodules=untracked
# Ignore all submodule changes
git status --ignore-submodules=dirty
# Same for git diff
git diff --ignore-submodules=dirtyYou can set this as a default in your Git config:
git config --global diff.ignoreSubmodules dirty
git config --global status.submoduleSummary false### Understanding Submodule State Reporting
Git reports submodule state by checking three things:
1. Commit state: Is the submodule at the commit the parent expects?
2. Index state: Are there staged changes in the submodule?
3. Working tree state: Are there modified or untracked files?
The "untracked content" message specifically refers to the working tree state. Even if you commit changes in the parent, this status won't change until the untracked files in the submodule are either:
- Added to version control
- Added to .gitignore
- Deleted
- Configured to be ignored via .gitmodules
### Nested Submodules
For nested submodules (submodules within submodules), you may need to apply the ignore configuration recursively. The --recursive flag helps with operations like git submodule update, but .gitmodules configurations need to be set in each level of the hierarchy.
### CI/CD Considerations
In CI/CD pipelines, "untracked content" can cause builds to fail if the pipeline checks for a clean working directory. Solutions:
- Use ignore = dirty in .gitmodules for CI reliability
- Add a cleanup step: git submodule foreach git clean -fd
- Configure the CI to use --ignore-submodules flags
### Performance Impact
Large submodules with many untracked files can slow down git status. If you have a submodule with many generated files (like a large build directory), using ignore = dirty can significantly improve performance.
### When Untracked Content Matters
Sometimes "untracked content" indicates a real problem:
- A contributor added files but forgot to stage them
- A build process created files that should be in .gitignore
- The submodule needs its .gitignore updated upstream
Before blindly ignoring untracked content, verify that the files are actually expected and not something that should be tracked or reported to the submodule maintainers.
warning: BOM detected in file, this may cause issues
UTF-8 Byte Order Mark (BOM) detected in file
fatal: Server does not support --shallow-exclude
Server does not support --shallow-exclude
warning: filtering out blobs larger than limit
Git partial clone filtering large blobs warning
fatal: Server does not support --shallow-since
Server does not support --shallow-since in Git
kex_exchange_identification: Connection closed by remote host
Connection closed by remote host when connecting to Git server