Skip to content

Instantly share code, notes, and snippets.

@anton0xf
Created June 29, 2012 19:33
Show Gist options
  • Save anton0xf/3020146 to your computer and use it in GitHub Desktop.
Save anton0xf/3020146 to your computer and use it in GitHub Desktop.
#!/bin/sh
if [ -z "$2" ]; then
echo "usage: git-cp-in-history FILE DIR"
exit 1
fi
FNAME="$1"
DNAME="$2"
git filter-branch --tree-filter \
'if [ ! -d "'"$DNAME"'" ]; then mkdir "'"$DNAME"'"; fi; '\
'if [ -f "'"$FNAME"'" -a ! -h "'"$FNAME"'" ]; then cp "'"$FNAME"'" "'"$DNAME"'"; fi' -- --all
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment