This is a weakness of SO and really the whole knowledge base business model (Q&A or not). You think you're building up this network-effect moat. "We have the best question-askers, answer-givers and answered questions. So everyone comes here!"
But, knowledge goes stale. "How do you X in JS?" is different than it was 10 years ago. People don't want a historical archive of how it was 10 years ago, they want to know today!
Then, like you say, GitHub brings in a whole new weird angle. Why ask on some other site when I have a spot where the maintainers and users hang out? Since my loyalty to SO is approximately zero, I'm just as likely to click on the Google result that takes me to GitHub if it looks more promising.