Skip to content

Instantly share code, notes, and snippets.

@Sharpie
Created January 25, 2012 22:23
Show Gist options
  • Save Sharpie/1679252 to your computer and use it in GitHub Desktop.
Save Sharpie/1679252 to your computer and use it in GitHub Desktop.
Shell script for stripping all Formula-related commits out of a Homebrew repository
#!/usr/bin/env bash
# Change to repository prefix so that git commands will work.
cd `brew --prefix`
# Ensure Homebrew is up to date and create a new branch called homebrew-core
brew update
git checkout master
git branch -D homebrew-core
git branch homebrew-core
# Create a ramdisk to run filter ops on in order to save the real disks some
# wear and tear.
diskutil erasevolume HFS+ "brew_core_tmp" `hdiutil attach -nomount ram://640000`
git filter-branch -f \
-d /Volumes/brew_core_tmp \
--index-filter "git rm -q -r --cached --ignore-unmatch Library/Formula Library/Aliases" \
--prune-empty homebrew-core
# Dispose of the RAM disk.
umount /Volumes/brew_core_tmp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment