Why do employers expect programmers to maintain public code repositories?

I just saw a video where a guy was harshly criticized for not being a “real developer” since he didn’t have a public code repository. This made me question if it’s fair to expect developers to showcase their work online.

It seems odd to me that tech professionals are expected to display their skills in their free time. You wouldn’t expect a window cleaner to share videos of their work during off-hours, or assume that a truck driver has to contribute something extra to prove their competence.

What’s with this expectation in the tech world that developers need to document their personal projects or contribute to open source? Does this really help assess a person’s skills?

Tech interviews can be misleading since candidates can easily present themselves well without genuine skills. Unlike other professions where results are visible, programming allows for memorized answers that may not reflect real ability. Employers often request access to GitHub to verify a developer’s experience and commitment to projects. However, this practice overlooks many capable developers who may be working on confidential projects or simply prefer not to code in their personal time. A more effective approach for companies would be to incorporate practical coding assessments rather than relying solely on a polished portfolio.