Created
March 14, 2012 15:42
-
-
Save cookrn/2037360 to your computer and use it in GitHub Desktop.
Ruby Script to Remove File FOREVER From Git Repo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Make a backup first! | |
# Place at the root of the desired git repo | |
# Run w/ commit SHA as first argument e.g. ruby fix.rb 57415b9c864e4128dca805b4a8ad7b7e59281ac6 | |
# | |
# All files in your list will be forever removed from the filesystem and git repo from given | |
# commit up to HEAD | |
files = %w( | |
you.r | |
list.of | |
fil.es | |
) | |
commit = ARGV[ 0 ] | |
command = "git filter-branch --index-filter 'git rm --cached --ignore-unmatch #{ files.join " " }' #{ commit }..HEAD" | |
puts command | |
# Uncomment the line below to actually run the command | |
# system command |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment