In a git repository, I have set up my .gitmodules file to reference a github repository:
[submodule "src/repo"]
path = src/repo
url = repourl
when I 'git status' on this repo, it shows:
On branch master
Your branch is up-to-date with 'origin/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)
modified: src/repo (new commits)
If I cd into src/repo and git status on repo, it says that there is nothing to commit.
Why is my top-level git repo complaining?
Best Answer
It's because Git records which commit (not a branch or a tag, exactly one commit represented in SHA-1 hash) should be checked out for each submodule. If you change something in submodule dir, Git will detect it and urge you to commit those changes in the top-level repoisitory.
Run
git diff
in the top-level repository to show what has actually changed Git thinks. If you've already made some commits in your submodule (thus "clean" in submodule), it reports submodule's hash change.Otherwise it shows
-dirty
hash change which you cannot stage or commit in the top-level repository.git status
also claims submodule has untracked/modified content.To update which commit records should be checked out for the submodule, you need to git commit the submodule in addition to committing the changes in the submodule: