d-_-b
d-_-b

Reputation: 23171

how dependent am i on git submodules?

When using git submodule functionality, how dependent am I on that repo's owner?

For example, I use git submodule add https://bitbucket.org/awesomecompany/repo.git

Everything is great... I can clone new versions, update and init the submodules, and everythign works as expected.

But then, one dreary day, the "awesome company" decides to delete their repository from bitbucket (or github). Now I try to clone my repo again, but git can't locate repo.git.

Am i screwed?

How should I have set up my project to not rely on their repo?

Am i not using submodules correctly?

Thanks!

Upvotes: 2

Views: 77

Answers (2)

Matthieu Moy
Matthieu Moy

Reputation: 16517

If you still have a local clone of your own project, it contains two things:

  • A .gitmodules file, tracked in your own repository, that contains the canonical URL of the submodule.

  • One directory .git/modules/$subproject per subproject, which is a local clone of the remote submodule. It's Git, it's distributed, you have a copy of the whole repository locally.

So, in case https://bitbucket.org/awesomecompany/repo.git disappears, you can still use your local repository of the submodule. You may push it to http://example.com/yourowncompany/yourownrepo.git, and let .gitmodules point to http://example.com/yourowncompany/yourownrepo.git for future versions, as if the submodule's project had just moved.

The good news is that the URL of the submodule is not stored in history. The Git history is all about unique identifiers (sha1sums) and does not care about where your code is hosted.

In any case, if the submodule is critical to you, you should maintain a reliably backed-up copy of it to avoid having to rely on your .git/modules/$subproject repository. As the other answer points out, if the submodule is hosted on a site that supports server-side forking (bitbucket, github, gitlab, ...), then keeping a fork is one way to do this.

Upvotes: 1

Samy Dindane
Samy Dindane

Reputation: 18706

  • You are screwed if you want to clone your repo. It's not lost if you already have it in your local repo.
  • Fork their project and update it frequently.
  • It's better to avoid relying on other people's projects if they're critical to yours. The usage in itself looks fine to me.

(that said, I guess relying on big projects is fine; they wouldn't disappear overnight, I guess)

Upvotes: 1

Related Questions