gitgithubrepositorygit-submodulesgit-remote

What happens to a git submodule when its referenced repo is deleted?


Suppose I find an interesting repository on github that I want to use, I add it as submodule and then one day the owner of the repo decide to delete the repo, would my submodule become broken?


Solution

  • You've still got the histories you already fetched, with submodule update or fetch or however you want to do it. You can still fetch those histories from any repo that has them, and push them wherever, it's the histories that matter, not which repo you or anyone keeps them in. The .gitmodules file is just notes on where to find them; when upstream deleted their repo those notes got outdated, but that's why git submodule init and git submodule update are separate commands: init loads your repo's config from the notes in .gitmodules and you can then change them as you like.