Git repos just aren’t designed to be synced by a file sync solution, but if you want to do that there’s nothing wrong with it. Maybe I just had a bad experience with things moving too fast for nextcloud and getting confused, but that can happen with any files and is not specific to git projects.
My point is that git projects should be synced to an actual git repo of some sort. If someone wants to build an integration to nextcloud that’s fine, I’m sure some people would use that. But remember, you would be pulling and pushing to that server just like you do with GitHub or anything else. Version control systems exist to let you commit only when you’re ready, with a message of your choosing. Not sure that can or should be automated.
And oh boy, gitlab would be an insane add on. If you thought installing the community document server was rough, wait till you install gitlab. It’s huge heavy on resources. On the other hand a light weight solution would be a little easier to manage.