tl;dr: correct way to add git to existing website project with dev subdomain on same shared hosting server?
I have some side project websites. They're all on shared hosting. I've never used version control on my side projects, instead I just created a subdomain for development (like dev.myproject.com) and copied updates as hotfixes to the live site. I want to keep that basic setup but add git into the mix.
So say I have two directories on my shared hosting: public_html and dev-myproject1. Both have complete sets of identical files, until I start making changes on dev. Once I'm done with changes on dev, I copy those changes to www.
What's the right way for me to set up git to bring version control into this workflow?
Do I git init my public_html folder and git clone from that into my dev-myproject1 folder? Or the other way around?
What's the minimum number of repos I need? Can I just use two, one for public_html and one for dev-project1?
This earlier question talks about needing uncompressed versions of files:
Is it possible for a Git branch to exist on the same server as the master branch?
Do I need separate additional folders for serving the actual websites to the public, or can public_html serve my files AND be a repository?
Seems like I could do this:
cd public_html
git init
git add .
git commit -m 'adding website project to git'
cd ~/dev-project1
git init
git clone ~/public_html
git add .
git commit
(make some changes to dev-project1 files)
git add .
git commit
git push ~/public_html
Is that correct - And is that the best way to do it?
FWIW:
I don't want to work locally. I want to keep doing all my work on the shared hosting server so I don't have to worry about environment differences.
I don't want to use an external repository hosting service like Github.
Thanks for helping me out on this.