Reputation: 7703
I have a git submodule which is constantly showing "modified" in git status even though I never update it.
# On branch master
# 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: MKNetworkKit (new commits, untracked content)
#
How do I stop git from thinking about it? I tried adding MKNetworkKit to .gitignore but it doesn't do anything.
Upvotes: 2
Views: 2584
Reputation: 150615
Is there any reason you don't want your local changes to the submodule updated in the repository? You are likely to break your code if you are expecting a submodule in a particular state, but the repository has it at an earlier state.
I suggest you commit the changes and push it to your repository.
If you want to reset the submodule to the state that the repository thinks it should be in, then run:
git submodule update
Which will reset it to the head sha as checked in to your repository.
If you want to carry on ignoring the updated repository, the other answers are useful.
Upvotes: 1
Reputation: 854
In my case it happened because i change remote repository protocol from git to https due to my proxy server policy. so, i change reference in .gitmodule dan .git/config. Then i run git submodule init
and git submodule update
. The submodule repository is succefully updated. :-)
To match revision of submodules, i checkout each submodule to latest revision by executing cd /path/to/submodule
and git checkout -f
.
If you want to keep changes in submodule but you does not want to push the changes to remote repository of submodule, you can add ignore = dirty
in .gitmodules
Upvotes: 2
Reputation: 1324218
Simply add:
git status --ignore-submodules
The question "How to get rid of git submodules untracked status?" proposes a more permanent way of masking that status, but if you are after temporarily hiding that information, --ignore-submodules
is enough.
From git status
man page:
--ignore-submodules[=<when>]
Ignore changes to submodules when looking for changes.
<when>
can be either "none
", "untracked
", "dirty
" or "all
", which is the default.
- Using "
none
" will consider the submodule modified when it either contains untracked or modified files or its HEAD differs from the commit recorded in the superproject and can be used to override any settings of the ignore option in git-config(1) or gitmodules(5).- When "
untracked
" is used submodules are not considered dirty when they only contain untracked content (but they are still scanned for modified content).- Using "
dirty
" ignores all changes to the work tree of submodules, only changes to the commits stored in the superproject are shown (this was the behavior before 1.7.0).- Using "
all
" hides all changes to submodules (and suppresses the output of submodule summaries when the config optionstatus.submodulesummary
is set).
Upvotes: 3