I'm interested in accurately removing a git repository in a reasonable time.But it takes quite a while to do so. Here, I have a small test repo where the .git folder is < 5MiB.$ du -ac ~/tmp/.git | tail -14772    total$ find ~/tmp/.git -type f | wc -l991Using shred's default options, this takes quite long. In the next command I use --force to change permissions and --zero to overwrite with zeros after shredding. The default shredding method is to overwrite with random data three times (-n3).I also want to remove the files afterwards. According to man shred, --remove=wipesync (the default, when --remove is used) only operates on directories, but this seems to slow me down even when I operate only on files. Compare (each time I reinitialized the git repo):$ time find ~/tmp/.git -type f | xargs shred --force --zero --remove=wipesyncreal    8m18.626suser    0m0.097ssys     0m1.113s$ time find ~/tmp/.git -type f | xargs shred --force --zero --remove=wipereal    0m45.224suser    0m0.057ssys     0m0.473s$ time find ~/tmp/.git -type f | xargs shred --force --zero -n1 --remove=wipereal    0m33.605suser    0m0.030ssys     0m0.110sIs there a better way to do it?EDIT: Yes, encryption is the key. I'm now just adding two more benchmarks using -n0. time find ~/tmp/.git -type f | xargs shred --force --zero -n0 --remove=wipe    real 0m32.907suser 0m0.020ssys     0m0.333sUsing 64 parallel shreds:time find ~/tmp/.git -type f | parallel -j64 shred --force --zero -n0 --remove=wipereal    0m3.257suser    0m1.067ssys     0m1.043s
How can I shred a git repository, reasonably fast?
git;data recovery;deleted files;shred
Forget about shred, it spends a lot of time doing useless things and misses the essential.shred wipes files by making multiple passes of overwriting files with random data (a Gutmann wipe), because with the disk technologies of 2030 years ago and some expensive laboratory equipment, it was possible (at least in theory) to recover overwritten data. This is no longer the case with modern disk technologies: overwriting just once with zeroes is just as good but the idea of multiple random passes stayed around well after it had become obsolete. See https://security.stackexchange.com/questions/10464/why-is-writing-zeros-or-random-data-over-a-hard-drive-multiple-times-better-thOn the other hand, shred utterly fails in wiping sensitive information, because it only wipes the data in the files that it is told to erase. Any data that was stored in previously erased files may still be recoverable by accessing the disk directly instead of via the filesystem. Data from a git tree may not be very easy to reconstruct; nevertheless this is a realistic threat.To be able to quickly wipe some data, encrypt it. You can use ecryptfs (home directory encryption), or encfs (encryption of a directory tree), or dm-crypt (whole-partition encryption), or any other method. To wipe the data, just wipe the key.See also How can I be sure that a directory or file is actually deleted?