Why not just store a second hash with a different algorithm, and check both hashes match?
This protection github is implementing uses a heuristic to try to find collision attempts by just looking at a single file. So it prevents github from hosting any collision attempts.