Search code examples
windowsgitgit-clean

Does git clean support moving to Recycle Bin?


I would feel much more comfortable using git clean if I knew I could undo the deletion in case something goes wrong.

Does it support Recycle Bin in any way, shape or form? If no, are there any workarounds that anyone knows of, such as an external tool using git clean -n to print out the files, and then moving them to Recycle Bin?


Solution

  • Put recycle.exe into your %PATH%

    Run git config --global alias.recycle !git_recycle.sh

    Put git_recycle.sh in your %PATH%:

    #!/bin/bash
    
    cd ${GIT_PREFIX:-.}
    git clean -xdfn "$@" | sed 's/Would remove //' | xargs -d \\n --no-run-if-empty recycle