Skip to content

Instantly share code, notes, and snippets.

@nderjung
Created June 13, 2019 21:41
Show Gist options
  • Save nderjung/4c9ccabc9945c797357796f38403f839 to your computer and use it in GitHub Desktop.
Save nderjung/4c9ccabc9945c797357796f38403f839 to your computer and use it in GitHub Desktop.
Clean git submodules
#!/bin/bash
# Context: you have a number of git submodules and those git repositories
# are now dirty with build artifacts. To completely clean the submodules
# and reset them to their original clone state, perform the following:
git submodule foreach 'git fetch origin; git checkout $(git rev-parse --abbrev-ref HEAD); git reset --hard origin/$(git rev-parse --abbrev-ref HEAD); git submodule update --recursive; git clean -dfx'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment