3

Have a git repo named parent-repo. It has folder lib with libraries. 'lib/one' is under control of parent-repo. And now I want to make git to recognize lib/one as git submodule of parent-repo.

cd lib/one
git init
git add .
git commit -m 'first commit'

I think next steps are 0) cd parent-repo, 1) untrack lib/one, 2) register lib/one as submodule 3) stage and commit.
Please clear next steps with git commands if it is possible.

kyb
  • 6,068
  • 4
  • 45
  • 81

1 Answers1

3

Current solution is create dedicated repo from that sources out of parent-repo. Move lib/one out of of parent-repo and create new git repository.

mv 'lib/one' ../one
cd ../one && git init && git add . && git commit -m 'first commit
# git remote add ... && git push

then

cd parent-repo
git submodule add --name one file:///path/to/one lib/one  # for example in windows file:///D/myrepos/one, file://../one relative path disallowed
git add lib/
git commit -m 'lib/one is submodule now'
kyb
  • 6,068
  • 4
  • 45
  • 81