Édouard Lopez
Édouard Lopez

Reputation: 43401

How to make/transform existing directory into git submodule?

So I'm having this project where some parts have been developed in the main repo but can be moved to an independently developed sub-module :

./                       ← repo root
├── client-angular/
│   └── whatever/
├── resources/
│   └── script/          ← wanna be sub-module
└── server-codeigniter/

Question

How can I make the script/ directory into a git submodule with minimal effort ? It is currently tracked by the main repo.

Upvotes: 3

Views: 853

Answers (1)

VonC
VonC

Reputation: 1324093

Once you have extracted the sub-folder in its own repo (as explained in "Detach (move) subdirectory into separate Git repository"), you will still have to:

  • push that new repo on a remote server (GitHub for instance)
  • git rm -r resources/script
  • and add the remote new repo as a submodule

    git submodule add /url/new/repo resources/scripts
    

Upvotes: 2

Related Questions