Skip to content

Instantly share code, notes, and snippets.

@Ickerday
Created June 20, 2018 13:20
Show Gist options
  • Save Ickerday/4e8bee4ab9ca73a49b7980197303f035 to your computer and use it in GitHub Desktop.
Save Ickerday/4e8bee4ab9ca73a49b7980197303f035 to your computer and use it in GitHub Desktop.
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