Home > Software design >  What if git submodule remote is deleted
What if git submodule remote is deleted

Time:10-12

I want to use a remote git repo as a library in my project and thought about adding it as a submodule to my git repo but than I thought: What if the submodule repo will be deleted? I sure would still have my local copy of it and could hop around in all the branches that I have locally but I never trust in anything that I have locally. Only what is on the server is what I trust. So if I ignore my "local backUp", the files would be lost in case that the remote server for the submodule isn't there anymore right? Or is there a mechanism for that?

So in that case I would be better of to copy the files from the submodule repo into my actual repo and commit all the files so that I actually have a copy of them on my server.

Am I missing something? Is there a better way to include external repos that I basically just want to read and use?

Thanks for all suggestions! Highly appreciate it!

CodePudding user response:

Use git subtree instead of submodule -> https://www.atlassian.com/git/tutorials/git-subtree

CodePudding user response:

I think I found a solution that works for me. Any suggestion on how to make this better of course is still highly appreciated:

  1. I opened up another repo on my server.
  2. I cloned the library repo that I want to include as a submodule in a separate directory
  3. Added my submodule repo server as a second remote in the dir of step 2
  4. pushed the branches from the library repo to my submodule repo
  5. included my submodule repo into my project as a submodule with the according branch

Seems a bit bulky but satisfies my paranoia.

  • Related