This file contains hidden or 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
#!/bin/bash | |
# adds a file to all commits in a git repository, as if it had always been there | |
# first arg is the path to the file to add | |
# second arg is relative path within the repository where the file should go | |
# this is much faster than `git filter-branch --tree-filter 'cp /path/to/file repo/path && git add repo/path' -- --all | |
cat $1 > /tmp/file-to-add | |
git filter-branch --index-filter "cat /tmp/file-to-add | git hash-object -w --stdin | xargs -L 1 -I X git update-index --add --cacheinfo 100644 X $2" --tag-name-filter cat -- --all |