How to force git submodule update –init to skip errors

git

I have my folder with active projects I’m working on and all of them are versioned as git submodules. When I set up a new work environment, I clone my folder using --recursive (or clone it normally and then do git submodule update --init --recursive. Just like link rot, sometimes there’s git remote repo rot (or a server may be down). In these cases I want to init/update only the repos that are available. However, git will stop updating at the first problem it encounters:

Cloning into 'dir/name'...
Connection closed by remote.host
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
Clone of 'user@example.com:path/to.git' into submodule path 'dir/name' failed

and the process stops there.

How can I force git to ignore such errors and just continue to the next submodule?

Best Answer

From this page I've found a way to exclude a submodule from submodule update. Suppose the module is dir/name. Then the recursive update-init command for all submodules except this one will look like

git -c submodule.dir/name.update=none submodule update --init --recursive

This doesn't automate skipping unforeseen errors, but works fine if you know that some particular submodule won't update.

Related Question