在hostmonster上搭建git server

hostmonster本身并不支持git,不过还好它提供了ssh,我们可以ssh上去编译git。

首先,ssh到hostmonster上,编译安装git

$ mkdir git
$ cd git
$ wget http://kernel.org/pub/software/scm/git/git-1.6.3.2.tar.gz
$ tar -zxvf git-1.6.3.2.tar.gz
$ cd git-1.6.3.2/
$ ./configure --prefix=$HOME/git
$ make  make install

修改~/.bashrc,设置环境变量

export GIT_HOME=$HOME/git
export PATH=$GIT_HOME/bin/:$GIT_HOME/lib/libexec/git-core/:$PATH

验证结果

$ source ~/.bashrc
$ git --version

我们在本地新建一个rails app来使用git server

$ rails home -d mysql
$ cd home
$ git init
$ git add .
$ git commit -a  -m "first commit"

忘了说了,你应该git init之后新建一个.gitignore文件

.DS_Store
log/*.log
tmp/**/*
config/database.yml

在本地生成一个只包含版本信息的版本库,并上传到hostmonster上,假设你要把你hostmonster上的版本库信息放在gits目录下

$ cd ../
$ git clone --bare home home.git
$ touch home.git/git-daemon-export-ok
$ scp -r home.git username@yourdomain.com:gits/

设置本地代码的远程版本库

$ cd home
$ git remote add origin usernmae@yourdomain.com:gits/home.git

之后就是修改代码,git pull/git push了

Posted in  hostmonster rails git


blog comments powered by Disqus
Fork me on GitHub