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

ronmichael October 25, 2012

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

0 votes
stevestreeting
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 25, 2012

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.

Filippo Bollini August 9, 2016

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

Many thanks,

0 votes
stevestreeting
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 25, 2012

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.

stevestreeting
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 25, 2012

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

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events