I would like to restore a whole directory (recursively) from the history of my git repository.
There is only 1 branch (master).
I know the commit where error
If you simply do git checkout then it will temporarily move you to that sha-commit.
Each commit object holds the entire structure of the disk at that time, so if you have files there and need to copy them out, you can do so. Warning though, you will not be in any branch, so you'll have to move back to master before copying the file into your working tree and commit it.