Git Submodules as a Package Manager

(nesbitt.io)

55 points | by ErenayDev 3 days ago

6 comments

  • unqueued 5 hours ago
    FYI A submodule doesn't have to use a gitfile and a corresponding `$GIT_DIR/modules/<name>` and there are good reasons not to. As long as the submodule has a '.git' it can be a symlink, or regular .git directory for a self contained embedded repo. You can still use the same gitlink in the parent repo representing it's commit id and git will still manage it.

    If I have a 20GB submodule I'd usually just do a `git clone <url> <path> && git submodule add <path>` and it will be treated the same by git. But now I can just delete it and it's purged. And it is more portable less fragile in some ways because it's not de-referencing a gitfile. I prefer my repos to be more bottom-heavy and to not clog my modules folder.

    I have a rough script that's the inverse of `git submodule absorbgitdirs` but it's a bit fragile.

    It would be cool if there was some plumbing to expose this a bit more.

  • AlphaSite 5 hours ago
    I know it sa toy, but if someone gets the bright idea to do this for real: please learn from npm and dont duplicate packages for every clone of a project. Share them between projects like every sane package manager.
    • matsz 57 minutes ago
      > Share them between projects like every sane package manager.

      I'd argue the other extreme is less sane. Pip installs everything system wide and you can't have different versions of the same package without venv.

      Even early NPM was much much better than the pre-uv Python situation. (TBH even with uv it still feels hacky at times.)

      • brabel 53 minutes ago
        The global repository should support versions obviously.
  • orliesaurus 5 hours ago
    I just have a feeling the developer-experience wouldn't be the same - but that's just a temporary issue perhaps?
  • bellowsgulch 3 hours ago
    I find https://github.com/andrewmcwattersandco/git-fetch-file more useful. It's manifest is nearly the same as a .gitmodules file, but having specific control over what files you want to pull, or what commit or tag, or just the equivalent of latest is way more practical day-to-day.
  • DarmokTanagra 4 hours ago
    [dead]
  • byako 2 hours ago
    [dead]