nginx deny directory and files to be downloaded

You can deny specific file types using

location ~* \.(git|rb|inc|ht)$ {
    deny all;
}