Skip to content

Instantly share code, notes, and snippets.

@xu-cheng
Last active March 6, 2016 11:08
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 xu-cheng/a7f788d28ea27c2722ff to your computer and use it in GitHub Desktop.
Save xu-cheng/a7f788d28ea27c2722ff to your computer and use it in GitHub Desktop.
Homebrew Rewrite git history
## extract Formula
git filter-branch -f --prune-empty \
--subdirectory-filter 'Library' \
-- --all
git filter-branch -f --prune-empty \
--index-filter \
'git rm --cached --ignore-unmatch -r -q -- . ; git reset -q $GIT_COMMIT -- Formula Aliases;' \
-- --al
## extract core
git filter-branch -f --prune-empty \
--index-filter \
'git rm --cached --ignore-unmatch -r -q -- Library/Formula Library/Aliases ;' \
-- --all
## rewrite commit history
git filter-branch -f \
--msg-filter 'sed -E -e "s/ (#[0-9]+)/ Homebrew\/homebrew\1/g"' \
-- --all
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment