The other methods didn't work for me since the commit had a lot of changes and conflicts to a lot of other files. What I came up with was simply
git show SHA -- file1.txt file2.txt | git apply -
It doesn't actually add
the files or do a commit for you so you may need to follow it up with
git add file1.txt file2.txt
git commit -c SHA
Or if you want to skip the add you can use the --cached
argument to git apply
git show SHA -- file1.txt file2.txt | git apply --cached -
You can also do the same thing for entire directories
git show SHA -- dir1 dir2 | git apply -