Search code examples
atlassian-sourcetree

Fully reset a corrupted git submodule in SourceTree


First off, I am not using command line git at all. I am only using SourceTree's gui interface. I would prefer to solve my problem this way; if possible.

Somehow, my submodule has become corrupted. Attempting to fetch or pull gives me the following error: enter image description here

I haven't found any answers for this particular problem. I am fortunate in that my remote master is ok, 100% up to date, and I have no local changes. So, I think the easiest way will be to just fully reset my local submodule.

However, I can't figure out how to do so.

I considered trying to remove my submodule and then re add it. However, I have had problems with that in the past, and so am gun shy.

I found handfuls of posts about resetting to a specific commit. However, the SourceTree gui is failing to populate my history because of this error.

Any help would be appreciated

Thank you


Solution

  • I finally did get this fixed. I had to give up and use the command line.

    I found this page (git fatal: failed to read object xxx: Invalid argument). That pointed me to using the "git fsck --full" command.

    That pointed me to a very specific folder in the .git hierarchy that was corrupted.

    I needed to delete this folder, but doing so wasn't easy. Windows would let me delete it. Not in safe mode. Not with cmd del or rmdir. I had to run a scan disk from windows on my entire drive. That ended up detecting the folder and removing it.

    Finally, from there, I was able to fetch and pull master again.