Sourcetree lost track of submodules

I'm using Git Flow mode and pushing git flow branch to repository, for some reason it's stopped tracking all of the submodules even though the .git files are still intact. Why would this be?

Now when I'm moving into master or develop, then back into /feature/some-feature (where they dissapeared), I'm getting error messages. On remote branches are checked as [-] (which I still not sure what this means, assuming not tracking remote changes?).

Files are still there but how would I reattach the submodules to local repository?

Thanks,

Rob

4 answers

1 accepted

So it seems somewhere along the way Sourcetree got confused about what submodule was pointing where, and stopped displaying the submodules. There are two possible areas where this could have happened in my case:

  1. I accidentally added the same repository submodule into two different folders, perhaps this caused a confliction in the setup as Sourcetree config had two entries for the same repository.
  2. Sourcetree got confused after I initially added a submodule in the wrong directory, subsequently deleted it, and recreated it again in the correct directory.

Either way, the following edit to the submodule records in my repository config file did the trick (and only after commiting the latest changes):

[branch "develop"]
    remote = origin
    merge = refs/heads/develop
[submodule "assets/less/vendor"]
    url = /Users/Rob/Sites/_/Frameworks/css/grid-systems/semantic-gs
[submodule "assets/js/vendor/semantic-gs"]
    url = /Users/Rob/Sites/_/Frameworks/css/grid-systems/semantic-gs
[submodule "assets/less/vendor/semantic-gs"]
    url = /Users/Rob/Sites/_/Frameworks/css/grid-systems/semantic-gs
[submodule "assets/js/vendor/html5shiv"]
    url = /Users/Rob/Sites/_/Frameworks/js/polyfills/html5shiv

So removing the duplicates, which were obviously the source of the problem results in:

[branch "develop"]
    remote = origin
    merge = refs/heads/develop
[submodule "assets/less/vendor/semantic-gs"]
    url = /Users/Rob/Sites/_/Frameworks/css/grid-systems/semantic-gs
[submodule "assets/js/vendor/html5shiv"]
    url = /Users/Rob/Sites/_/Frameworks/js/polyfills/html5shiv

Perhaps SourceTree needs some fine-tuning when it comes to duplicate/deleted submodules?

It sounds simple compared to the other answers, but what helped me was a 'git submodule init' in the git shell (terminal) and the submodule did reapear in SourceTree.

Hey Rob,

Submodules are relatively complex. The first place you'll want to check is the .gitmodules file to see if they're actually configured. When you switch branches during your git flow it may be that the .gitmodules file is being changed or completely blanked out meaning git won't be able to read your submodules. If you want to add them back you can just re-add them from the sidebar as with my previous statement they're likely not to be in your .gitmodules file. You'll need to provide the original remote clone URL though as the repository needs to know where they came from.

Hope that helps, if not just give us an update so we can look into it further :)

Thanks Kieran, I'll check that out — I'd assumed they'd be transferred over using the Git Flow method, I take it unlikely anything irretrievably broken, so long as you point the .gitmodules file to the original files? Will it pick up the .git file provided you enter in the correct path? Or will it reset the git file/folders?

The .gitmodules file is as it should be, everything's pointing to it's proper place. What now?! On the Git config file for the git-flow branch I have duplicate entries:

[branch "develop"]
	remote = origin
	merge = refs/heads/develop
[submodule "assets/less/vendor"]
	url = /Users/Rob/Sites/_/Frameworks/css/grid-systems/semantic-gs
[submodule "assets/js/vendor/semantic-gs"]
	url = /Users/Rob/Sites/_/Frameworks/css/grid-systems/semantic-gs
[submodule "assets/less/vendor/semantic-gs"]
	url = /Users/Rob/Sites/_/Frameworks/css/grid-systems/semantic-gs
[submodule "assets/js/vendor/html5shiv"]
	url = /Users/Rob/Sites/_/Frameworks/js/polyfills/html5shiv

Which all should be pointing to different paths/urls like in my correct .gitmodules file. I did accidentally put the semantic-gs into the wrong folder and deleted it a couple of times — could that be the issue? Actual .gitmodules file looks like:

[submodule "assets/js/vendor/easytabs"]
	path = assets/js/vendor/easytabs
	url = https://github.com/JangoSteve/jQuery-EasyTabs.git
[submodule "assets/js/vendor/hashchange"]
	path = assets/js/vendor/hashchange
	url = https://github.com/cowboy/jquery-hashchange.git
[submodule "assets/less/vendor/semantic-gs"]
	path = assets/less/vendor/semantic-gs
	url = /Users/Rob/Sites/_/Frameworks/css/grid-systems/semantic-gs
[submodule "assets/js/vendor/html5shiv"]
	path = assets/js/vendor/html5shiv
	url = /Users/Rob/Sites/_/Frameworks/js/polyfills/html5shiv

Hi all,

Old issue. But thought I would mention my solution to the same problem.
[SourceTree 1.8.1 on OSX Mavericks]

To start
[SomePath]/MainRepoRoot/
- ABC/
-- SubModule_A/
-- SubModule_B/
-- SubModule_C/
- DEF/
-- SubModule_A * clone from same origin as ./ABC/SubModule_A

The lead event:
- ABC exists with the three submodules ... all working fabulously
- Via command line, I cloned SubModule_A into ./DEF from the same origin (located far far away)

In SourceTree, I opened up the "MainRepoRoot" and clicked to add the ./DEF/SubModule_A as a submodule
This crashed (and reported)

Reopened SourceTree and it had lost track of all submodules


Tracking towards Resolution:

Closed (Quit) SourceTree

Command line: "git submodule" --- Returns an error
No submodule mapping found in .gitmodules for path 'DEF/SubModule_A'

Incidentally, the git command returned an exit code of '1' (error)
Thus, I believe, SourceTree aborts looking for submodules and thus they don't appear in the sidebar
Okay. Makes Sense.

The Fix:
Manually added appropriate entry to MainRepoRoot/.gitmodules
(Since I cloned several projects, I added those too)

Ran 'git submodule' again and it succeeds (exit code = 0)

Opened SourceThree

All of the submodules appear properly in the sidebar (with relative paths too - that's nifty:)


Hope this helps someone else - perhaps even myself next time I run into this and end up google'ing only to find my own answer! lol :)



Side note:
- SourceTree stability on OSX MountainLion was great - the very rare crash.
- However, since migrating to Mavericks (and using same git repos) I get far far far more frequent crashes - on the order of once a day. Hopefully there is a new version coming soon with bunches of fixes. (I'll keep reporting issues since I imagine that helps!:)

Otherwise, great work and thanks for SourceTree!


Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Jodi LeBlanc
Posted Thursday in Off-topic

Friday Fun: How do you recharge your batteries after a busy week?

Happy Friday – Fun Day! I don’t know about you, but I have been giving everything I’ve got this week (and most weeks) and come Friday I look for unique ways to recharge my batteries - rest, relax, a...

189 views 21 4
Join discussion

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