git alias to clean/reset all repositories in a directory

I want to clean/reset all git repositories in a directory recursively.

If I execute the following command it works as expected:

  • Diff only changed parts of lines
  • Unable to install the latest version of Gitlab
  • calling git diff in pre-commit shell script
  • How to find latest non-merge commit message in Git?
  • Git SSH access setup issue
  • Git Pull command in shell script without having to enter password manually?
  • find . -name .git -type d -execdir sh -c "git clean -xdf" \;
    

    I have problems converting the command to a git alias:

    xxx = "!f() { find . -name .git -type d -execdir sh -c "git clean -xdf" ; ; }; f; "
    

    I have tried to fix the errors such as syntax error near unexpected token;’` however I am going in a circle with no success.

    Please help me to create the alias. 10x

  • How to fetch all git branches
  • will adding .gitconfig in repository override my global .gitconfig file configurations?
  • What do (s)witch, (i)gnore, (w)ipe, (b)ackup options mean when installing a package from repository using pip?
  • Find which repository I cloned
  • Git (1.8.1.2) error when adding interactively
  • Symbolically linking files inside a git subdirectory
  • One Solution collect form web for “git alias to clean/reset all repositories in a directory”

    Here you go:

    xxx = "!f() { find . -name .git -type d -execdir git clean -xdf \\; ; }; f"
    

    A few things:

    • No need to wrap the command in sh -c, you can use it directly
    • You need to escape the \ in \; at the end of the find command, writing as: \\;
    Git Baby is a git and github fan, let's start git clone.