I'm using Git 2.17.2 on Mac. Somehow the submodule I was using in my project got screwed up and I would like to re-import (connect?) the submodule from scratch. Within my project, I removed the directory
davea$ git rm DBConnector
and then ran
davea$ git submodule add https://myuser@dev.azure.com/MainCo/SubCo/_git/DBConnector
A git directory for 'DBConnector' is found locally with remote(s):
origin https://dev.azure.com/MainCo/SubCo/_git/DBConnector
If you want to reuse this local git directory instead of cloning again from
https://myuser@dev.azure.com/MainCo/SubCo/_git/DBConnector
use the '--force' option. If the local git directory is not the correct repo
or you are unsure what this means choose another name with the '--name' option.
thinking I messed up something earlier, I tried
davea$ git submodule rm DBConnector
usage: git submodule [--quiet] add [-b <branch>] [-f|--force] [--name <name>] [--reference <repository>] [--] <repository> [<path>]
or: git submodule [--quiet] status [--cached] [--recursive] [--] [<path>...]
or: git submodule [--quiet] init [--] [<path>...]
or: git submodule [--quiet] deinit [-f|--force] (--all| [--] <path>...)
or: git submodule [--quiet] update [--init] [--remote] [-N|--no-fetch] [-f|--force] [--checkout|--merge|--rebase] [--[no-]recommend-shallow] [--reference <repository>] [--recursive] [--] [<path>...]
or: git submodule [--quiet] summary [--cached|--files] [--summary-limit <n>] [commit] [--] [<path>...]
or: git submodule [--quiet] foreach [--recursive] <command>
or: git submodule [--quiet] sync [--recursive] [--] [<path>...]
or: git submodule [--quiet] absorbgitdirs [--] [<path>...]
so I'm a little confused. What do I need to do to re-add this submodule from scratch and clear out any references to it that may be preventing my re-adding it?
I think instead of doing a git rm
on a submodule, it is advised to do a git submodule deinit
(might as well use the --force
option in case you have any unmodified changes). After that, do a git submodule add
and I think that should fix the problem.
Feel free to comment if there is any problem in this method!
Best
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.