How do I work with a git repository within another repository?

Viewed 142832

I have a Git media repository where I'm keeping all of my JavaScript and CSS master files and scripts that I'll use on various projects.

If I create a new project that's in its own Git repository, how do I use JavaScript files from my media repository in my new project in a way that makes it so I don't have to update both copies of the script when I make changes?

5 Answers

Quite a lot of projects, modular in nature (more so since git favours not-so-big repositories), don't need a full-fledged configuration stage: you just layout a number of repositories within a given set of relative locations and you are done.

In this scenario should be easy to work with this, and this, and this repo, which is what the likes of git submodules, subtrees, etc. try to acomplish. They are up to the task, but I don't think they can be considered easy nor not error prone.

"Git repos within git repos" doesn't need to be difficult: please see my simplest-git-subrepos example.

Related