Skip to content

Instantly share code, notes, and snippets.

@luzpaz
Last active May 3, 2022 13:33
Show Gist options
  • Select an option

  • Save luzpaz/c450aba42444d2d69ba75309f4cd1b60 to your computer and use it in GitHub Desktop.

Select an option

Save luzpaz/c450aba42444d2d69ba75309f4cd1b60 to your computer and use it in GitHub Desktop.
FreeCAD-Addons Guidelines

How to update the FreeCAD-Addons repo

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"

How to add a submodule

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 .gitmodules alphabetically i.e. move the new submodule to it's rightful alphabetical location.

How to rename a submodule

How to change a submodule repo url

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

How to remove a submodule

Notes

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>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment