I've added a submodule in my main git folder tree and haven't changed anything but it's showing up modified. What do I do about this?
$ git status
# On branch master
# Changed but not updated:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: example.com/soundmanager
#
no changes added to commit (use "git add" and/or "git commit -a")
I've tried a git submodule update, but it doesn't do anything.
gitmodules file to update the URL and then run git submodule sync --recursive to reflect that change to the superproject and your working copy. Then you need to go to the . git/modules/path_to_submodule dir and change its config file to update git path.
You can fix it by: either committing or undoing the changes/evolutions within each of your submodules, before going back to the parent repo (where the diff shouldn't report "dirty" files anymore). To undo all changes to your submodule just cd into the root directory of your submodule and do git checkout .
Submodules are now regarded as dirty if they have any modified files or untracked files, whereas previously it would only be the case if HEAD in the submodule pointed to the wrong commit.
The way that the status of git submodules is reported has changed a lot over recent versions of git, so you should really include the output of git --version
as well for us to be able to help accurately.
However, in any case, the output of git diff example.com/soundmanager
should tell you more. If you see output with the same commit name, but with -dirty
added to the new version, e.g.:
diff --git a/example.com/soundmanager b/example.com/soundmanager
--- a/example.com/soundmanager
+++ b/example.com/soundmanager
@@ -1 +1 @@
-Subproject commit c5c6bbaf616d64fbd873df7b7feecebb81b5aee7
+Subproject commit c5c6bbaf616d64fbd873df7b7feecebb81b5aee7-dirty
... than that means that git status
in the submodule isn't clean - try cd example.com/soundmanager
and then git status
to see what's going on.
On the other hand, if you see different commit versions, e.g.:
diff --git a/example.com/soundmanager b/example.com/soundmanager
index c4478af..c79d9c8 160000
--- a/example.com/soundmanager
+++ b/example.com/soundmanager
@@ -1 +1 @@
-Subproject commit c4478af032e604bed605e82d04a248d75fa513f7
+Subproject commit c79d9c83c2864665ca3fd0b11e20a53716d0cbb0
... that means that the version that your submodule is at (i.e. what you see from cd example.com/soundmanager && git show HEAD
) is different from the version committed in the main project's tree (i.e. what you see from git rev-parse HEAD:example.com/soundmanager
). If the former is right, you should add and commit the new version of the submodule in your main project, with something like:
git add example.com/soundmanager
git commit -m "Update the soundmanager submodule"
On the other hand, if the latter is what you want, you can change the version that the submodule is at with:
git submodule update example.com/soundmanager
I used the following git command to resolve this problem:
git submodule update --init --recursive
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With