git submodule project failed to create submodule

//执行git命令 为当前项目创建自模块
git submodule add http://*********/*********/zrp/z.git src/zrp/z



//报错信息 因为之前创建过子模块后来删除了 现在再创建相同自模块会报错,
//手动删除本地自模块所在文件夹
//后 git/config 文件中删除子模块对应配置信息
 [submodule "codes/src/zrp/z"] 
    url = http://*********/*********/zrp/z.git
	active = true
//依然报错
fatal: 'codes/src/zrp/z' already exists in the index

The solution is as follows

1. Delete the files corresponding to the submodules in the modules folder under git.

2. Command line execution 

git rm --cached codes/src/zrp/z

3. Re-add the submodule and execute the following three lines of instructions to create the submodule successfully.

git submodule add http://*********/*********/zrp/z.git src/zrp/z
git submodule init  
git submodule update

Guess you like

Origin blog.csdn.net/uniquepeng/article/details/128918958