Google was already using GitHub ("To meet developers where they are, we ourselves migrated nearly a thousand of our own open source projects from Google Code to GitHub.") and added an "export to GiHub" button on google code. Maybe if you were .net you went to codeplex but most everyone else (including Google) went to GitHub, if they weren't already there.
https://opensource.googleblog.com/2015/03/farewell-to-google...
That happened in 2015. Everyone was already on GitHub by then. GitHub had surpassed in usage Sourceforge, Code, and CodePlex from 2011. Also CodePlex didn't had Git support until 2012.
The only real question at the time was whether Git or Mercurial (or for a brief period of time Bazaar if I remember correctly). While Mercurial itself was clearly superior to Git, it had no equivalent to GitHub.
If GitHub had chosen to build their workflows on Mercurial instead we would likely be talking about HgHub right now instead.
There existed BitBucket (it still exists, but as far as I am aware they switched to offering Git hosting).
When MS also announced they were closing that and offering a tool to migrate to GitHub, was when GitHub (and Git) truly became the biggest remaining option.
The other aspect of SourceForge's decline was that they doubled down on the sketchy site feeling right as acceptance of such sites was on the decline, the likes of mediafire, zippyshare etc were being replaced with cloud storage providers and download aggregators were losing popularity (in part due to also becoming very sketchy and prone to pushing malware). They might've been able to get away with it a few years earlier. I remember that back then it wasn't a huge deal to follow a mediafire download link from somewhere that seemed reliable enough, whereas nowadays it'd be an immediate red flag due to the abundance of more legitimate seeming file sharing options.