git CLI

Table of Contents

Run commands while not in a git directory howto

git -C ~/foo status  # equivalent to (cd ~/foo && git status)

Delete empty directories within a repository howto

find . -type d -empty -not -path './.git/**' -delete

Purge files including their histories howto

git clone --mirror git@github.com:yeonghoey/yeonghoey.git
java -jar ~/.local/bin/bfg.jar --strip-blobs-bigger-than 1M yeonghoey.git
cd yeonghoey.git
git reflog expire --expire=now --all && git gc --prune=now --aggressive
git push

List all TODOs written by a specific user howto

git grep -l TODO | xargs -n1 git blame -f -n -w | grep "$(git config user.name)" | grep TODO | sed "s/.\{9\}//" | sed "s/(.*)[[:space:]]*//"