5

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

  1. cd parent-repo
  2. untrack lib/one
  3. register lib/one as submodule
  4. stage and commit.

Please clear next steps with git commands if it is possible.

vvvvv
  • 25,404
  • 19
  • 49
  • 81
kyb
  • 7,233
  • 5
  • 52
  • 105

1 Answers1

4

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
  • 7,233
  • 5
  • 52
  • 105