Skip to content

Instantly share code, notes, and snippets.

@victorprocure
Last active July 10, 2019 21:00
Show Gist options
  • Save victorprocure/1520caac1e3378d8dfb68e9cb052e8c4 to your computer and use it in GitHub Desktop.
Save victorprocure/1520caac1e3378d8dfb68e9cb052e8c4 to your computer and use it in GitHub Desktop.
Well used git
## BEGIN Remove folder retroactively
git filter-branch -f --tree-filter 'rm -rf FOLDERNAME' --prune-empty HEAD
git for-each-ref --format="%(refname)" refs/original/ | xargs -n 1 git update-ref -d
echo FOLDERNAME >> .gitignore
git add .gitignore
git commit -m "Fixing git repo REMOVED: FOLDERNAME"
git gc
git push -f origin master
## END Remove folder retroactively
## BEGIN Remove all files retroactively from repo
git filter-branch -f --tree-filter "find . -type f -name '*.extension' -exec rm {} \;" --prune-empty HEAD
git for-each-ref --format="%(refname)" refs/original/ | xargs -n 1 git update-ref -d
echo *.extension >> .gitignore
git add .gitignore
git commit -m "Fixing git repo REMOVED all files with EXTENSION"
git gc
git push -f origin master
## END Remove all files retroactively from repo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment