What is difference between git submodule and git package

75 Views Asked by At

If we want to use github repository in our projects, we can use it in two different ways: (1) by using git submodule (2) by adding the repository as a git package in the dependency file.

How to choose between two approaches?

1

There are 1 best solutions below

0
Jake Lee On

git submodule = A feature of git, whereby you can add the repository as essentially embedded inside your own repository. This is usually only used when you own the embedded repository. Official description (more info):

A submodule is a repository embedded inside another repository. The submodule has its own history; the repository it is embedded in is called a superproject.

git package = Depends on the environment you're working in as this doesn't seem to be standard, but this is likely just adding the dependency as a third party library. This is almost always what you will want.

One way to think of it is using submodules means git controls your dependency. Using packages means whatever framework you are using controls your dependency. This is usually best.