Skip to content

Instantly share code, notes, and snippets.

@kjbrum
Forked from nicktoumpelis/repo-rinse.sh
Last active September 29, 2022 13:16
Show Gist options
  • Save kjbrum/a8591a4a776543c6e3371754f304d490 to your computer and use it in GitHub Desktop.
Save kjbrum/a8591a4a776543c6e3371754f304d490 to your computer and use it in GitHub Desktop.
Clean and reset a Git repo and/or it's submodules.

Clean and reset a Git repo and/or it's submodules

Remove untracked/ignored files/directories and uncommitted changes.

Repo and submodules

$ git clean -xfd
$ git submodule foreach --recursive git clean -xfd
$ git reset --hard
$ git submodule foreach --recursive git reset --hard
$ git submodule update --init --recursive

Submodules only

$ git submodule foreach --recursive git clean -xfd
$ git submodule foreach --recursive git reset --hard
$ git submodule update --init --recursive

Extras

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