download my resume ― firstname.lastname@example.org
You can use Git to push changes of a website-or project-you manage. No changes (just an addition of a resource) are required to your local repository.
In essence we are setting up a remote git repository (which can be considered a good idea, in case your hard-drive takes a hit).
Your remote repository will receive one change (or hook).
$ mkdir /srv/git/project && cd /srv/git/project $ git init --bare
You can use any directory you wish, I just host my git repositores under
Then we create a hook:
ne /srv/git/project/hooks/post-receive and insert the following inside that file:
#!/bin/sh GIT_WORK_TREE=/var/www/project-deployed git checkout -f
Like above, where ever you serve up web-pages from.
Then make it executable.
chmod +x /srv/git/project/hooks/post-receive
You do have to do one thing locally (technically not a change to the repository; lets call it an update).
When you’re in your local git repository, just add a
$ git remote add deployed ssh://server.example.org/srv/git/project $ git push deployed +master:refs/heads/master
If you utilize a custom
SSH port, the first command would look like:
$ git remote add deployed ssh://server.example.org:PORT/srv/git/project
Just remember to change
:PORT to the actual port number your server uses.
Whenever you want to update your website, a simple:
git push deployed will update your live site.