Skip to content

Instantly share code, notes, and snippets.

@Ickerday
Created June 20, 2018 13:20
Embed
What would you like to do?
Unfuck git (remove ignored but tracked files)
#!/bin/sh
if ! [ -d .git ]
then
echo >&2 Not in top level of a git repo
exit 1
fi
# 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