svn revert file.rb == git checkout -- file.rb

You’ve changed a file, but don’t want to commit it. Ever. I do this all the time, maybe disabling a filter so I can hit a page with curl, maybe hard-coding a specific user id to test something. In subversion, you would “revert” that file.

svn revert file.rb

In git, you don’t add that file to your staging area for commit. To make your changes go away forever, you checkout a new copy of that file from HEAD.

git checkout -- file.rb

If you omit the –, it will still work, as long as you don’t have a branch named the same as your file. Thanks to Jonathan Dance at norbauer.com - one of the few blog entries I found describing this technique.

2009-04-28 UPDATE - err has a great git cheatsheet that includes this trick under Fixing Mistakes.