Turns out to be quite easy:
- Identify the hash of the revision you want to revert to, e.g. abc123
- At the command prompt, type:
git checkout abc123 path/to/file
Why would I need to do this? Don’t ask But I definitely took something to heart: git positively encourages you to create branches, and I don’t do it enough. If I had made a branch for the single feature I had a problem with, instead of rolling it into a general “development” branch, I wouldn’t have been at the computer at 9:30 pm tearing my hair out trying to roll back individual files! Lesson learned. But I do one thing right: atomic commits. Make sure each commit relates to a single feature, then at least it’s easy to identify affected files. Commits of unrelated fixes are a Bad Thing.