Skip to content

Instantly share code, notes, and snippets.

@adurbalo
Last active August 2, 2023 12:33
Show Gist options
  • Save adurbalo/f1626e3fea5761e667f075f8ceb95ccf to your computer and use it in GitHub Desktop.
Save adurbalo/f1626e3fea5761e667f075f8ceb95ccf to your computer and use it in GitHub Desktop.
Clean up git repo

To remove the “leftover” submodules after checking out a different branch, you can run the following. This command will recursively clean the main repository and all submodules.Warning: this will remove all untracked files as well.

git clean -xffd && git submodule foreach --recursive git clean -xffd

To see which files will be deleted without actually deleting yet, add the -n flag.

git clean -nxffd && git submodule foreach --recursive git clean -nxffd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment