I would like to set up Git to work on my site so I can can
- I have a repo on my computer (
index.php,contact.php, etc) - Set up my webserver (hostgator) so that I can commit to the server
- Make it so that when I commit, the website’s code changes as that’s the code I’m working on
All the tutorials that I saw show how to push it onto github which is not what I’m looking for. Also I don’t want and git files to be viewable because it contains some PHP passes and stuff in them.
I plan on having different projects on my site. So for now there’s one subfolder like /forums that have all the files for that but later I may create another project so I’ll make each folder into it’s own repo.
Are there any tutorials or video tutorials on how to do this? Any blogs or such? I jest need a nudge in the right direction
You should have SSH access to your web server.
Connect to your webserver using SSH, and create the initial
repository there (
git init).Then, clone this repository in your computer (
git clone).Add the website files into the repository (
git add), and commit(
git commit). Commits in git are always local. You need topush them to the remote repo. So…
Push your changes to the webserver repository (
git push)To “checkout” these changes automatically to your website, you need
to add a post-receive hook (see https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks)