Git repo is only part of that solution.
The primary reason for difficulty switching to another 'git host' (gitlab, github, https://git.sr.ht/, or self hosted) is issue tracking...
That is true, but it's also not something that is essential or needs to live on Github. I've seen projects that direct users to Launchpad for issue tracking, but accept PRs on Github, for example.
In the worst case, you will lose issue discussions, but you will never lose the code.
And that.... is why projects on Github won't leave github easily.
Sure, but do they need to? I thought it was simply ridiculous when projects left for gitlab.com after Microsoft acquired Github. Admittedly, Gitlab is better software, but I don't think this played a big part.
If the project maintainers really cared about not being hosted by one of the biggest data empires on the planet, they should have moved away from proprietary services altogether. But that would have reduced visibility and ease of use for contributors.
Of course, this could partially be solved with better commit messages, but who has time for that eh ;)
Well, you should consider writing these anyway. Just like good code comments. Think about much easier it will be to understand your own code after 2 years. ;)
(who mirrors his projects on github, but has a private original of the repo self hosted; issue tracking thus is public and private...).
I think this is the best of both worlds.