Skip to content

Instantly share code, notes, and snippets.

@s3cur3
Created December 21, 2020 19:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save s3cur3/9f856f0e055cdedbad240a044b02d568 to your computer and use it in GitHub Desktop.
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
#!/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