Revert changes to a specific file from a specific commit

git

Solution

Get a patch-ready diff for that file in that commit, and then reverse-apply the patch:

git show <commit-id> -- <path> | git apply -R -

Make sure you like the result, and if so, add and commit with appropriate message.

Problem

A few weeks ago (i.e. many commits ago), I made a git commit that touched many files. Most of the commit was great. However, I'd now like to undo the changes that I'd made to just one of those files, but I don't want to override any changes that had been made to that file after that commit. Is there a way for me to revert a specific commit but only on one of the files in that commit?

Original source

Related problems