Skip to content

Instantly share code, notes, and snippets.

Created June 20, 2018 13:20
What would you like to do?
Unfuck git (remove ignored but tracked files)
if ! [ -d .git ]
echo >&2 Not in top level of a git repo
exit 1
# Remove _every_ file from tracking
git ls-files | xargs git rm --cached
# re-add everything (now gitignored files will be ignored)
git add .
echo Check your changes
git status
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment