How to add sub-repo as sub-module

In order to contribute a open source project autojump, I clone it into my daily repo. When I staged it, the adding embedded git repository warning appears:


git add Open\ source/github.com

warning: adding embedded git repository: Open source/github.com/hustnzj/autojump

hint: You've added another git repository inside your current repository.

hint: Clones of the outer repository will not contain the contents of

hint: the embedded repository and will not know how to obtain it.

hint: If you meant to add a submodule, use:

hint:

hint: git submodule add <url> Open source/github.com/hustnzj/autojump

hint:

hint: If you added this path by mistake, you can remove it from the

hint: index with:

hint:

hint: git rm --cached Open source/github.com/hustnzj/autojump

hint:

hint: See "git help submodule" for more information.

The warning tip is pronounced so the solution is simple:


$ git rm --cached Open\ source/github.com -r

$ git submodule add https://github.com/hustnzj/autojump Open\ source/github.com/hustnzj/autojump

Adding existing repo at 'Open source/github.com/hustnzj/autojump' to the index

$ git status

On branch daily

Changes to be committed:

(use "git restore --staged <file>..." to unstage)

modified: .gitmodules

new file: Open source/github.com/hustnzj/autojump

$ git commit -m 'Open source contribution: autojump'
本作品采用《CC 协议》,转载必须注明作者和本文链接
日拱一卒
讨论数量: 0
(= ̄ω ̄=)··· 暂无内容!

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!
未填写
文章
93
粉丝
85
喜欢
153
收藏
121
排名:71
访问:11.4 万
私信
所有博文
社区赞助商