In my scripts, I often use libraries (mine or others’) that have their own repos. I don’t want to duplicate those in my repo and get stuck with updating them every time a new version comes out.
However, when somebody clones the repo, it should still work locally and not have broken links.
Any ideas about what I could do?
You can do this with submodules in git. In your repository, do:
So, if the library’s repository had a URL of
git://github.com/example/some_lib.gitand you wanted it atlib/some_libin your project, you’d enter:Note that this needs to be done from the top-level directory in your repository. So don’t
cdinto the directory where you’re putting it first.After you add a submodule, or whenever someone does a fresh checkout of your repository, you’ll need to do:
And then all submodules you’ve added will be checked out at the same revision you have.
When you want to update to a newer version of one of the libraries,
cdinto the submodule and pull:Then, when you do a
git statusyou should seelib/someliblisted in the modified section. Add that file, commit, and you’re up to date. When a collaborator pulls that commit into their repository, they’ll seelib/somelibas modified until they rungit submodule updateagain.