Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What happens when a Git submodule goes 'offline'?

I"m still trying to figure my way out around Git submodules. Let's say I'm using submodules pointing to a public repository to which I only have read access.

What happens to my project when that repository is taken offline and is no longer accessible?

like image 796
Sid Avatar asked Mar 23 '23 16:03

Sid


2 Answers

That's one of the beauties of git/DSCM: your local clone is a complete standing repository. Submodules are no exception.

Any "central" repository is simply a location where developers of a project agree to push changes to. Write access in simplest terms means that you get to push to this pre-agreed upon location. Theoretically you could even network multiple "central" repo hosts and have developers push to each one, or have each repo run hooks to sync with each other.

Because every clone of a git repository (including submodules) is a complete repo by itself, if that central official push location gets changed, or disappears you still have a completely working repository with full read/write access to your local clone.

In the case that the official submodule project developers decide that they simply wanted to relocate their "central" clone, all you have to do is update your submodule's remotes to point to the new, correct location.

see:

GitHug: Adding a remote

GitBook: Remote Branches

GitBook: working with Remotes

Update

Suppose that your project can be accessed by other people. This implicitly means that these user would also need access to any submodules your project uses.

You could re-host your local submodules (known as "forks") and modify your main project repo to refer to the forked repos. This is preferred over copy/paste, and may be a good idea even if the official repo is still around. This is dependent upon the license the original project was provided under, of course.

Few reasons why this is a good idea:

  1. You can make changes to your fork without having been granted write access to the official central repo.
  2. If the official central repo goes dark, you still have a complete live version for anyone who wants to check out your project.
  3. Unlike the copy/paste version, it's relatively easy to keep a forked repo in sync with the official repo. Plus, you get to keep all of the branches and history of the original repo, where-as with copy/paste you just get an initial copy commit history item.
  4. The submodule repo maintainers may decide to incorporate some of your changes back into the "official" version. Again, relatively easy to do if they have a complete repo clone to work with (which a submodule is).
like image 151
helloworld922 Avatar answered Apr 01 '23 04:04

helloworld922


In a way submodules are are viewed as separate repositories. So if your submodule repo goes offline - there is no way to update a submodule.

When you use a submodule you imply that the repo is accessible to all the developers throughout dev cycle.

Only use submodules for relatively stable components.

like image 23
Ruslan Osipov Avatar answered Apr 01 '23 04:04

Ruslan Osipov