Created
October 13, 2025 13:46
-
-
Save wilcorrea/24ed6e6d4a26fdcc5c651196e4a7b6c9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Disable git pager | |
| export GIT_PAGER=cat | |
| untracked=$(git clean -d --dry-run) | |
| changes=$(git status --short) | |
| if [ -z "$untracked" ] && [ -z "$changes" ]; then | |
| echo "Nothing to purge, working tree clean" | |
| exit 0 | |
| fi | |
| git status | |
| echo "" | |
| read -p "Purge working tree? (y/N) " confirm | |
| if [ "$confirm" = "y" ]; then | |
| git clean --force -d | |
| git reset --hard | |
| echo "Working tree purged" | |
| else | |
| echo "Operation cancelled" | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment