Git is another awesome tool developed and maintained by Linus Torvalds who wrote linux kernel. In this post I’ll explain how can we use it for our site maintenance. I have a vps on which my site is hosted along with a mail server, git server and a web server too. But I’m sure this guide can be used with shared hosting accounts with some modifications.
Install git. Once installed, as root user, create git
user and add it to www-data
group.
|
|
Login into this new git
user.
|
|
Create an ssh directory for this account.
|
|
Upload your user ssh public key to this directory how you want. I use pastebin here. Assuming you pasted your public key somewhere on pastebin, I’ll fetch it using curl.
|
|
Create a directory for your user you wanna use for your site or this user may be the one you use to login to your vps using ssh. I’ll use user z
for this post.
|
|
Create a git repo here now.
|
|
Create a hook in .git
directory.
|
|
That’s it. Now go to the directory where your site is hosted, in this example we used /var/www/html
for site and z
as username which is used to maintain our site in future using git like in above hook we used that. You can modify both hook and here this code too according to your needs.
|
|
We have made it. Now in your local machine, clone this repo this way.
|
|
cd into the directory you just cloned, do some modifications and push the changes and you’ll see the magic.