How to add sub-repo as sub-module

hustnzj發表於2022-08-31

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 協議》,轉載必須註明作者和本文連結
日拱一卒

相關文章