Ni ada 40 langkah saya susun khas untuk guna GIT. Disebabkan ramai yang bertanya di ruang maya ini, saya rasa terpanggil untuk berkongsi perihal pemasangan GIT ini. Ini saya belajar semasa berada di ofis lama. Moga memberi manfaat kepada yang memerlukan, InsyaAllah.
Installation and Configuration for GIT On Server Centos 5.4
Installation
------------
1) Install the dependencies
$ yum install gettext-devel expat-devel curl-devel zlib-devel openssl-devel gcc
2) Change directory
$ cd /usr/local/src
3) Get the git source code
$ wget http://kernel.org/pub/software/scm/git/git-1.7.1.1.tar.gz
4) Untar the git source code
$ tar xzvf git-1.7.1.1.tar.gz
5) Change Directory
$ cd git-1.7.1.1
6) Install from source using configure and make command
$ ./configure
7)
$ make
8) Install Git
$ make install
9) Test it
$ git --version
git version 1.7.1.1
Configuration
-------------
10) SSH to server
$ ssh user3@x.x.x.x
11) Change directory
$ cd /home/user3
12) Create new folder
$ mkdir git-mysystem
13) Change directory
$ cd git-mysystem/
14) Copy from source
$ cp -R /var/www/html/mysystem/* /home/user3/git-mysystem
15) Initialize git repository
$ git init
Initialized empty Git repository in /var/www/html/git-mysystem/.git/
16) Description (optional)
$ echo "My System" > .git/description
17) Edit .gitignore
$ nano .gitignore
Add:
app/tmp
app/config/database.php
app/webroot/files
18) Tell git to take a snapshot of the contents of all files under the current directory
$ git add .
19) Commit
$ git commit -m 'Initial commit'
20) Check log
$ git log
21) To allow git push from client PC
$ git config --bool core.bare true
On local:
22) Change directory
$ cd /var/www
23) Config the user which will be used by git
$ git config --global user.name 'Ali Bin Ahmad'
24) Same for the email addess
$ git config --global user.email alibinamhad@gmail.com
25) To set up a new repo on your local computer, use the following syntax:
$ git clone user3@x.x.x.x:/home/user3/git-mysystem
26)
$ git remote rm origin
$ git remote add origin user3@x.x.x.x:/home/user3/git-mysystem
$ git config branch.master.remote origin
$ git config branch.master.merge refs/heads/master
27) Status, add, commit and push
$ git status
$ git add .htaccess
$ git commit -m "missing file"
$ git push
Create Development Repository
-----------------------------
On Server:
28) $ su root
29) $ cd /var/www/html
30) $ git clone /home/user3/git-mysystem
31) $ chown user3:user3 git-mysystem -R
32) $ exit
Optional:
$ cp -R /var/www/html/mysystem/app/tmp /var/www/html/git-mysystem/app/
$ cp -R /var/www/html/mysystem/app/config/database.php /var/www/html/git-mysystem/app/config/
$ cp -R /var/www/html/mysystem/app/webroot/files /var/www/html/git-mysystem/app/webroot/
33) $ git remote add origin /home/user3/git-mysystem
34) $ git config branch.master.remote origin
35) $ git config branch.master.merge refs/heads/master
36) $ git pull
Auto Git Pull
-------------
37) $ cd /home/user3/git-mysystem/.git/hooks
38) $ cp post-receive.sample post-receive
39) $ nano post-receive
Add:
cd /var/www/html/git-mysystem
git --git-dir /var/www/html/git-mysystem/.git --work-tree /var/www/html/git-mysystem pull
Copy To Production
------------------
40) $ git archive --format=zip HEAD > archive.zip
#zairo