Local package in git submodule

Hi,
I am working on a project in which I develop a couple of different packages (and also keep a fork of a public package). I wanted to use git sub-modules to keep that in check. Specifically the tree looks something like

Project
├── .git [FOLDER]
├── .gitmodules
├── Manifest.toml
├── Project.toml
├── data
├── scripts
│   └── script.jl
└── src
    ├── Package1
    │   ├── .git [FILE]
    │   ├── Project.toml
    │   └── src
    │       └── Package1.jl
    └── Package2 
        ├── .git [FILE]
        ├── Project.toml
        └── src
            └── Package2.jl

Unfortunately I cannot ]add src/Package1 since it’s not a git repo but a git submodule:

(Project) pkg> add src/Package1
ERROR: Did not find a git repository at `src/Package1`

I could add the remote but that would decouple the commits of the Packages and those of the Project using them which is the exact reason I was trying to do this. Also, that seems overly complicated to be honest.

Is there a solution to this, either from the Julia side or the Git side?

Also, if I’m doing something that should not be done and there is a better way, I don’t mind changing since right now my project is fairly easy to manage and can be switched to another format.

Best regards

The easiest is probably to use dev src/Package1 which would point to that local file path. The second option would be to use add with a subdirectory: add .:src/Package1. Note that they have slight differences: dev uses the current state on the file system while add uses the content of the last commit.

4 Likes

Wow, thank you so much, this is perfect!
And thank you for both suggestions, both will come in extremely handy.

1 Like