How do I easily keep track of the status of Git submodules?

In SouceTree (latest version) if I make a change to some code in a submodule there appears to be no indication at all in the main repository of that change. I'd have to remember to open the submodule to see it.

Am I missing something? Is this by design? We're looking at using submodules in some scenarios where the code there will be updated, but I'm afraid without some kind of visual indicator in the root project that people will forget to check in their submodule code changes.

2 answers

Git actually ignores uncommitted changes to any nested submodules until you commit those changes, at which point it shows up in the parent repo as a change to the submodule commit that you're tracking.

However, SourceTree supplements this by checking if there are uncommitted changes to your submodules when you try to commit or push the parent. This check is optional (you can disable it in Preferences > Git > Check submodules before commit & push) because some people don't like the extra time it takes to check this when you hit commit/push, but it can be very useful in the kinds of circumstances you describe.

So although you won't see uncommitted changes to submodules in the parent repo, you will get reminded about them when you try to commit or push. SourceTree even lets you commit the submodule changes as a nested dialog inside the parent commit dialog when this occurs so you can do it all in one joined-up sequence.

Hope that helps.

Just to clarify, the check happens when you confirm the commit / push dialog in the parent repo.

Oh, and I totally forgot that there's something else - in the sidebar, SourceTree queries submodule state for you and will display an annotation of '...' if there are uncommitted changes, like so:

If you've committed and haven't pushed, it's an up arrow.

Is this still true? I am using version under Windows and I see no hint in the SUBMODULES section of the main repo regarding the state of its submodules.

Many thanks,

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Oct 23, 2018 in Sourcetree

Tip from the team: configure your repos for hosting goodness!

Supported Platforms macOS Windows We recently introduced support for additional hosting services such as GitHub Enterprise, GitLab (Cloud, Community Edition, Enterprise Edition), and...

1,110 views 4 2
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you