gitvisual-studio-code

Managing multiple interdependent git repositories - unification vs symbolic links


Up until today, I was able to manage seven repositories using a single view of the Source Control tab of VS Code.

Basically, I have 6 embedded firmware projects that run on different platforms, each in their own repository.

I then have a single shared repository where I keep all of the header files/drivers that are shared by all of these projects.

Each project repository contains a symbolic link to the place where the shared repository is cloned on my local machine so that the application structure is like:

symlink in folder tree

Today when I opened up VS code, I see that this is no longer working.

I used to be able to force VS code to "add the repository" to the source control view using Git Graph: Add Git Repository... but that now throws errors:

The folder "c:/PARTICLE_LOCAL/jaza_embedded" is not within the opened Visual Studio Code workspace, and therefore could not be added to Git Graph.

I can get the symlinked repo to show up in the source code management tab if I manually add the local folder to the workspace though:

shared folder added to vs code workspace redundantly at workspace root

both repositories now showing in Git management tab

I tried:

I expected:

What resulted:

What I am considering and would like help with:

I am considering unifying all of these git repositories into a single one, since I need the shared portions of the repositories to be the same for each project in the repo whenever I am compiling. My concern is about how to do this, and what "gotchas" or downsides there are in unifying 7 repositories into a single one.


Solution

  • First, I've tested git operations with POSIX symlinks. They work if the appropriate option is available (git config core.symlinks true, git config --get core.symlinks to test it). The symlinks between files work immediately, but for symlinks between directories, git requires configuration of submodules. So far, so good.

    It's good that you've come to the same conclusion as I did: merging all of these repositories into a single one is the only solution that makes sense. Anyway, let's overview the situation with the POSIX symlink. Basically, hardlinks, symlinks, and NTFS junctions (reparse points) are associations between the file system objects (files or directories, it does not matter) that make that object graph an arbitrary graph, not necessarily a tree (a tree is a graph without loops). From the revision control system standpoint, it makes no essential difference between the pure-tree set of file system objects and arbitrary graphs. Why?

    This is because a git repository always works with a set of file system objects of the same file system, and this is quite a reasonable approach. Only then the repository clone can be placed at any point of a local file system without losing any dependencies. Yes, git can refer to foreign repositories, but this is done through URL references, because different repositories, strictly speaking, are technically independent. POSIX links between different repositories would not make any sense, because cloning two different repositories at arbitrary locations would break those links anyway. All the above is a schematic proof of this fact, but it can be proven in a much stricter way.

    You also need to take into account your practical reason: you require the possibility to modify files on all the repositories of the solution.

    So, let's talk about merging the repositories into one. The first important key (#1) is to create a brand-new git repository. Another key (#2) is that you need to plan the migration and the development in two or more stages, it is important to keep the possibility to retreat your steps and rethink the general design. Let's assume you have four already functioning repositories, A, B, C, and D. The tentative steps may look like this:

    This is a quick sketch. Please comment if I missed something, then I would be able to modify or add something.