Git submodule - track a subfolder of a foreign Git repo

251 Views Asked by At

Say we are using git submodule:

git submodule add https://github.com/user/repo

I am wondering if there is a way to tracker a specific folder, something like this:

git submodule add https://github.com/user/repo -- xxx

is something like this possible?

For example, say we we have this in our .gitmodules file:

[submodule "config"]
    path = config
    url = https://github.com/user/repo.git

so what I am looking for is the config folder in my local project to reflect the xxx folder in the other/remote repo.

1

There are 1 best solutions below

0
On

is something like this possible?

Not that I know of.

One way would be to:

  • add the submodule in one folder

    git submodule add https://url/repo afolder
    
  • record a symlink to the right submodule subfolder

    ln -s afolder/xxx xxx
    git add xxx