Can't add git submodule when specified as a relative path

前端 未结 3 470
不思量自难忘°
不思量自难忘° 2020-12-25 11:10

I\'m trying to add a submodule to my git repo, and I\'m getting this error in return:

remote origin does not have a url defined in .git/config
3条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-25 11:29

    (I've summarized just the solution here. Credit goes to VonC.)

    In the containing repository (say containing.git/), git interprets relative paths as relative to the origin remote, which is not defined. We want it to be relative to the containing.git/ directory, so run

    git remote add origin ..
    

    (Not sure why it's .. rather than ..)

    Now you can add the sub-module:

    git submodule add ../extern/Lib1 lib
    

提交回复
热议问题