Heads up everyone. I’m moving my main blog back to www.matschaffer.com.
Tumblr has been pretty good to me, but I got frustrated the lack of comments and difficulty posting code snippets. This will likely be my last post to tumblr, so please update your feedreaders and bookmarks accordingly.
Tim Bray came to talk to us at CIM. I was extremely gratified when he started the talk by essentially telling us all to at least learn Rails. I guess it’s time for me to do that rails brownbag.
We got a recording for posterity too. Thought I don’t get the impressions we’ll be permitted to release it. :(
So a few days ago I accidentally checked a bunch of my mp3s into the git repo for matschaffer.com. This blew out the size of .git and made clones a pain. So I wanted to remove it. I got some help from “jast” in the git IRC channel which set me straight.
In this case I had committed and pushed the mp3s, then committed one more change after that. So the bad commit was HEAD^^, but I also had HEAD^ that I wanted to keep.
Here’s what I did:
# Save any changes after the bad commit
git format-patch HEAD^
# Reset everything back to the bad commit
git reset --hard HEAD^^
# Remove the accidentally checked in file
git rm --cached thefile
# Amend the bad commit
git commit --amend
# Restore the other change from patch file
# Clean up. Note this will eliminate any chance of undo-ing this process
git reflog expire --expire=0 --all
git prune --expire 0
# If you need to, you can force a push to correct the history on a remote repo as well
git push -f
After this my local .git was still pretty big (as was the server’s repo). But any new clones were nice and small. So I just created a new clone, and copied that up to the server via scp and all was well. It was a bit of a pain, but it was neat that git is capable of doing these sort of operations. Under subversion you’d need a system administrator to do this sort of stuff.