git – using git to manage website

in web development, we always store file in htdocs/www/’anything’ in doc root config
besides git versioning, we also can make to auto update our htdocs folder

this scenario, the server use ubuntu-server
and crunchbang (debian) in workstation

at server
# create repo folder, i use [foldername].git to make easy

u@svr:/opt$ mkdir suropati.git && cd suropati.git

# and folder in

u@svr:/opt/suropati.git$ mkdir /www/suropati.live

# init git repository

u@svr:/opt/suropati.git$ git init --bare
Initialized empty Git repository in /opt/suropati.git/

# buat file hooks post-receive

u@svr:/opt/suropati.git$ nano hooks/post-receive

pada file post-receive, masukan kode berikut

#!/bin/sh
GIT_WORK_TREE=/htdocs/suropati.live git checkout -f

buat script tersebut dapat di eksekusi

u@svr:/opt/suropati.git$ sudo chmod +x hooks/post-receive

selesai config pada sisi server, sekarang configurasi pada sisi workstation anggapan disini, kita telah melakukan setting git pada local repository maka selanjut nya adalah, melakukan configurasi agar repository local tersebut dapat melakukan push dengan mudah ke server setting add remote

gw@g3n1k:/web/conektp$ git remote add web ssh://git@192.168.1.196://opt/suropati.git

lakukan push pertama ke server

gw@g3n1k:/web/conektp$ git push web +master:refs/heads/master
Enter passphrase for key '/home/gw/.ssh/id_rsa':
...
* [new branch]      master -> master

untuk push kedua dan seterus nya, gunakan perintah

gw@g3n1k:/web/conektp$ git push web

untuk mengecek konfigurasi sudah berjalan seperti yang diharapkan,
tampilkan isi folder /htdocs/suropati.live

u@svr:/htdocs/suropati.live$ ls

http://toroid.org/ams/git-website-howto

Published by

G3n1k

just to remember what i had known :)

One thought on “git – using git to manage website”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s