Skip to content

Instantly share code, notes, and snippets.

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 uliwitness/cbb9e3b51f1aba71a633658de3e145b4 to your computer and use it in GitHub Desktop.
Save uliwitness/cbb9e3b51f1aba71a633658de3e145b4 to your computer and use it in GitHub Desktop.
Extract individual files from a Github repository
#!/bin/bash
GIT='/Applications/Xcode.app/Contents/Developer/usr/bin/git'
#$SOURCEREPO=$1
#$DESTREPO=$2
SOURCEREPO=/Users/uli/Programming/FileExplorer/UliKit
DESTREPO=/Users/uli/Programming/FileExplorer/ULIXattrMetadataStore
MYDIR=`dirname "$0"`
$GIT clone --no-hardlinks "$SOURCEREPO" "$DESTREPO"
echo "===== REMOVE REPO CONNECTIONS: ====="
cd "$DESTREPO"
$GIT remote rm origin
$GIT tag -l | xargs $GIT tag -d
echo "===== FILTER START: ====="
git filter-branch --prune-empty --index-filter "git ls-files | sed \"s/'/\\\'/g\" | sed 's/\"/\\\\\"/g' | grep -vE 'UKXattrMetadataStore.h|UKXattrMetadataStore.m|.gitmodules|.gitignore' | \"$MYDIR/quietxargs.sh\""
echo "===== FILTER END. ====="
$GIT reset --hard
$GIT for-each-ref --format="%(refname)" refs/original/ | xargs -n 1 $GIT update-ref -d
$GIT reflog expire --expire=now --all
$GIT gc --aggressive --prune=now
#!/bin/bash
xargs -0 -I{} git rm -rf --cached --ignore-unmatch "{}"
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment