Skip to content

Instantly share code, notes, and snippets.

@thomseddon
Last active December 11, 2015 23:28
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 thomseddon/4676397 to your computer and use it in GitHub Desktop.
Save thomseddon/4676397 to your computer and use it in GitHub Desktop.
Simple bash script to clean MULTIPLE unwanted files out of a git repo
#!/bin/bash
#
# Usage: ./gitclean.sh <branch> <path-to-match>
# Requires clean working tree (i.e. delete files in <path> and commit)
#
# Thom Seddon <thom@seddonmedia.co.uk>
git ls-tree --name-only -r $1 $2 | while read FILE; do
git filter-branch --index-filter "git rm --cached ${FILE}" HEAD
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment