To prevent accidental leaks perhaps Github et al could implement a mechanism analogous to the Eurion constellation [0]. E.g. A commit containing a file with a specific text pattern should always be rejected. Most fileypes accept arbitrary comments (ahem Json) so it should work for most files.
0: https://en.m.wikipedia.org/wiki/EURion_constellation