Created
December 21, 2020 19:07
-
-
Save s3cur3/9f856f0e055cdedbad240a044b02d568 to your computer and use it in GitHub Desktop.
Nukes all the untracked files that Git checkout complains about, then actually performs the checkout
This file contains 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 | |
if git checkout "$1" ; then | |
echo "No untracked files had to be deleted" | |
else | |
git checkout "$1" 2>&1 > /dev/null | grep $'\t' | xargs rm | |
git checkout "$1" | |
echo "Deleted conflicting untracked files" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment