Skip to content

Instantly share code, notes, and snippets.

@cite
Last active April 6, 2017 06:50
Show Gist options
  • Save cite/1dd3de5c06e066e949915e85e4b1467d to your computer and use it in GitHub Desktop.
Save cite/1dd3de5c06e066e949915e85e4b1467d to your computer and use it in GitHub Desktop.
PREFIX=data
SQL=/tmp/rewrite-history.sql
:>$SQL
git filter-branch \
--index-filter '
git ls-files -s |
sed "s,\t,&'"$PREFIX"'/," |
GIT_INDEX_FILE=$GIT_INDEX_FILE.new git update-index --index-info &&
mv $GIT_INDEX_FILE.new $GIT_INDEX_FILE
' \
--commit-filter '
n=$(git commit-tree "$@")
echo "UPDATE patch_sets SET revision = '\''$n'\'' WHERE revision = '\''$GIT_COMMIT'\'';" >> '$SQL'
echo $n
' HEAD
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment