It's not at all obvious they'd lose. Github is not violating anybody's copyright. They're only distributing source code, presumably with the full consent of the authors.
Github doesn't need to violate copyright. Github would be sued under a contributory infringement theory (i.e., the same one that took down napster and kazaa), and could be found liable for the infringement committed by others. The point of the DMCA safe harbor is that by responding to takedown notices (and by not deliberately hosting infringing material), they are immune to infringement actions for hosting infringing material.