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:

  • Running MinGW/MSYS tools inside msysgit
  • Git Bash command not found after installing a package
  • Create multi-word alias in bash?
  • How to set aliasses in the Git Bash for Windows?
  • Append git's branch name to command prompt
  • How can I set up autocompletion for Git commands?
  • 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

  • Is there a difference between git reset --hard HEAD and git checkout .?
  • git log <since> <until> shows all log instead of specified
  • Git and WordPress (+ managing plugins and media)
  • How do I place a dummy file in a git repo?
  • How do you push just a single Git branch (and no other branches)?
  • Understanding when to use git commit -m and git commit -am
  • 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.