The situation:
I have a repository that has a submodule.
Normal people (like me) don't have read permissions for this submodule which isn't really a problem as it isn't required to run the project.
My problem is that every time I check something out I get errors telling me that the submodule update failed because the submodule remote couldn't be read:
fatal: Needed a single revision
Unable to find current revision in submodule path
no surprise ...
I tried to remove it manually from .gitmodules and then use
git update-index --assume-unchanged .gitmodules
but this only works until the next checkout as submodules seem to get special treatment.
I tried putting .gitmodules into .gitignore or .git/info/exclude but git ignored that, reported .gitmodules as changed and gave me the original one again at checkout.
My question:
How do I suppress these errors and completely ignore the existence of this submodule locally... including all further remote changes that try to reintroduce it?
Note: Please assume that the solution has to stay on my end and requires no changes on the remote side... as they will not happen (already tried talking to the repo admin)
It's a bit difficult to replicate this situation, but as per discussion in comments
git submodule deinit -f .
helped. If someone stumbles here, from documentation one might find out that during init, actual git pull
is done on submodule. So If You had no permissions to access remote submodule repository, locally git had no master branch, no commits to checkout, and that was the meaning behind error message.
Update: if you are using a gui like SourceTree or SmartGit, check the repository settings and disable the auto-update of submodules.
Depending on your setup only disabling "Initialize new submodules" may already fix the problem: