git pull
###############################################
# git submodule foreach git checkout master
# Skip certain submodules https://stackoverflow.com/a/58292036
# for repos with default branch named: 'master'
git submodule foreach 'case $name in MnesarcoUtils|SlopedPlanesMacro|Design456|OpticsWorkbench|Beltrami|Trails|SearchBar|AnimationFreeCAD) ;; *) git checkout master ;; esac'
# for repos with default branch named: 'main'
git submodule foreach 'case $name in MnesarcoUtils|SlopedPlanesMacro|Design456|OpticsWorkbench|Beltrami|Trails|SearchBar|AnimationFreeCAD) git checkout main ;; esac'
###############################################
# git submodule foreach git pull
# Skip certain submodules https://stackoverflow.com/a/58292036
# for repos with default branch named: 'master'
git submodule foreach 'case $name in MnesarcoUtils|SlopedPlanesMacro|Design456|OpticsWorkbench|Beltrami|Trails|SearchBar|AnimationFreeCAD) ;; *) git pull origin master ;; esac'
# for repos with default branch named: 'main'
git submodule foreach 'case $name in MnesarcoUtils|SlopedPlanesMacro|Design456|OpticsWorkbench|Beltrami|Trails|SearchBar|AnimationFreeCAD) git pull origin main ;; esac'
###############################################
git add .
git commit -m "Updated revisions"
git pull
git submodule add https://github.com/easyw/Defeaturing_WB.git Defeaturing
git commit -m "Adding Defeaturing workbench"
git push
The crux of the commmand is git submodule add <GitAddress> <AddonName>
Important Notes
- If you don't supply an AddonName, it will take the same name as the one used on github (in this case Defeaturing_WB).
- The git address you will find under the "clone or download" green button on github repo pages
- Before submitting the commit, please sort the
.gitmodulesalphabetically i.e. move the new submodule to it's rightful alphabetical location.
git submodule set-url <'path' exactly how it's written in .gitmodules> <new url>
Reference .gitmodules to see the name of the submodule you're updating url for example:
$ grep CfdOF .gitmodules
[submodule "CfdOF"]
path = CfdOF
so CfdOF is the path we use:
git submodule set-url CfdOF https://gitlab.com/opensimproject/cfdof.git
If a submodule is removed sometimes it's cache is still left behind. You can test this using
git submodule status
or when running a git submodule foreach... you see an error like
fatal: no submodule mapping found in .gitmodules for path <submodule name>
or
fatal: No url found for submodule path '<submodule name>' in .gitmodules
Solution:
git rm --cached <name of submodule>