Skip to content

Instantly share code, notes, and snippets.

@IQAndreas
Created January 7, 2013 22:10
Show Gist options
  • Save IQAndreas/4478999 to your computer and use it in GitHub Desktop.
Save IQAndreas/4478999 to your computer and use it in GitHub Desktop.
#!/bin/bash
if [ $# -lt 1 ]; then
echo "[clear-git-directory.sh] Please specify the GIT repository to clear."
exit 1;
elif [ ! -d "$1/.git" ]; then
echo "[clear-git-directory.sh] Cannot find a GIT repository in '$1'."
exit 1;
else
cd "$1";
shopt -s extglob dotglob;
rm -rf !(.git);
fi
# --- OUTPUT ---
$ utils/clear-git-directory.sh bin
utils/clear-git-directory.sh: line 12: syntax error near unexpected token `('
utils/clear-git-directory.sh: line 12: ` rm -rf !(.git);'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment