Back to TILs

git - como limpar submódulos

Date: 2020-01-07Last modified: 2023-03-07
git submodule foreach --recursive git clean -xfd

Para dar reset no repositório e seus submódulos use:

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

Dependendo da configuração pode ser necessário incluir mais um -f

If the Git configuration variable clean.requireForce is not set to false, git clean will refuse to delete files or directories unless given -f, -n or -i. Git will refuse to delete directories with .git sub directory or file unless a second -f is given. Use force twice to clean directorise with .git subdirectories: git clean -xfdf. I had some tangling submodules that would not get deleted with just git clean -xfd.

Referências