Sunday, February 12, 2012

Reverting With git Subversion Style

I was already familiar how to reset the entire head of my git repositories to a desired state, but what if I needed to revert the changes in one specific file which I had managed to bugger up while keeping all my other changes.  The only reason this was hard because my brain is still slightly working in subversion language:

git checkout filename

so just check out the version of the file you want.  This will land you in trouble if you have a banch with the same name as the file, in which case you can do:

git checkout -- filename