Skip to content

Instantly share code, notes, and snippets.

@moritzebeling
Forked from myusuf3/delete_git_submodule.md
Last active July 24, 2020 18:35
Show Gist options
  • Save moritzebeling/f5ef9ff2250ca4ce90db60f6e2289ced to your computer and use it in GitHub Desktop.
Save moritzebeling/f5ef9ff2250ca4ce90db60f6e2289ced to your computer and use it in GitHub Desktop.
Some git snippets

Gitting around

To clone a repo with all its submodules:

  • git clone --recursive [git://url]

Add a submodule

  • git submodule add [git://url] [path/to/submodule]

Load submodules if they weren’t when cloning

  • git submodule update --init

Update all submodules:

  • git submodule foreach git pull origin master

Removing a submodule:

  • Delete the relevant section from .gitmodules
  • Stage the .gitmodules changes with git add .gitmodules
  • Delete the relevant section from .git/config
  • Run git rm --cached [path/to/submodule] (no trailing slash)
  • Run rm -rf .git/modules/[path/to/submodule] (no trailing slash)
  • Run git commit -m "Removed submodule [Name of Module]" to commit the change
  • Delete the now untracked submodule files rm -rf [path/to/submodule]

Load remote branches:

  • git fetch origin

Kirby meets Git https://getkirby.com/docs/cookbook/setup/git

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