> I've been working with git lately, trying to do some unusual things, > and I need to say this is one of the least suckless pieces of software > I've ever worked with. It's complex, obscure, inconsistent, quirky...
> tell what you did Ok, here is one day in the life of messing about with git. Let's say you wanted to get rid of all history from a repo, just keep the current commit. Git lets us rewrite history, so this should be easy, right? Wrong. I won't tell you how long it took to find this weird technique: #!/bin/sh -e new_root_hash=`git rev-parse HEAD` echo "$new_root_hash" >.git/info/grafts git filter-branch -f rm .git/info/grafts At least it runs quickly. Let's say you want to garbage collect your repo after getting rid of that unwanted history... git gc whoops, it does not work. final hacky 'solution' (after quite some research and experiment): #!/bin/sh -ev git remote rm origin || true git for-each-ref --format="%(refname)" refs/original/ | xargs -n1 --no-run-if-empty git update-ref -d ( cd .git rm -rf refs/remotes/ refs/original/ *_HEAD logs/ ) git -c gc.reflogExpire=0 -c gc.reflogExpireUnreachable=0 -c gc.rerereresolved=0 -c gc.rerereunresolved=0 -c gc.pruneExpire=now gc "$@" But ordinary things are famously weird in git, also.