It'd be a useful feature for github and bitbucket to have a default pre-commit that scans for probably-sensitive files and reject commits like that (maybe with a repo setting to opt out on the website, if you think you know what you're doing)
edit: In fact, they should probably run a full search for such files now and email a heads-up to users with repos that produce hits.