4 How to do stuff with git
10 ##### Remove history of all but select files in cloned repo
15 $ git gc --aggressive --prune=now
16 $ git remote rm origin
20 git ls-tree -r --name-only HEAD \
21 | grep -v file_i_want_to_keep_1 \
22 | grep -v file_i_want_to_keep_.. \
23 | grep -v file_i_want_to_keep_n \
24 | xargs git rm --cached -r --ignore-unmatch
27 $ git gc --aggressive --prune=now
30 ##### Remove history of previously-removed (not in current tree) files
32 $ git log --pretty=format: --name-status \
33 | awk '$0 != "" {print $2}' \
34 | sort -u > /tmp/tree.old
35 $ git ls-tree -r --name-only HEAD > /tmp/tree.new
39 grep -Fvxf /tmp/tree.new /tmp/tree.old \
40 | xargs git rm --cached -r --ignore-unmatch
46 Inserting a new root commit
47 ---------------------------
49 git checkout --orphan $TEMP_BRANCH
51 git commit --allow-empty -m $INIT_COMMIT_MSG
52 git rebase --onto $TEMP_BRANCH --root $MAIN_BRANCH
53 git branch -d $TEMP_BRANCH