0

I've a Github project and I want to add submodule like following How to link folder from a git repo to another repo?

when I run the command

git submodule add https://github.com/expressjs/express

it works

But when I run

git submodule add https://github.com/expressjs/express/tree/master/lib

I got error not found , I want to add to my repository only sub folder and not all the repository, how can I do that ?

1 Answers1

0

You can not add only a sub-folder, because it is not a repository but just a part of the repository. git submodule is for mounting one repository inside another.

One possible alternative: Take the sub-folder that you want to use, split it out into a stand-alone repository, and then embed it into both projects (repositories) via submodules. You can maintain the commit history of this folder as well while making it a standalone repo using git filter-branch.

Detailed Description: https://blog.github.com/2016-02-01-working-with-submodules/#switching-to-submodules

Roshan Br
  • 362
  • 2
  • 17