假设你已经在本地搭建了一个git repository,现在需要把它上传到dreamhost主机上提供给别人pull,并方便自己在不同电脑上更新使用。这是我目前用的方法,当然首先你得先知道以下东西(以下内容均为假设,表胡猜我的帐号,密码了:D)
- DH主机名: montty (假设)
- DH用户名: hades (需开通shell操作权限)
- 本地Git repo: /home/hades/software
1.在DH主机上安装Git
ssh登陆DH主机,在主目录下进行以下操作安装Git
$ mkdir src && cd src/
$ wget http://kernel.org/pub/software/scm/git/git-1.5.4.4.tar.gz
$ tar xzvf git-1.5.4.4.tar.gz
$ cd git-1.5.4.4
$ ./configure --prefix=/home/hades/ NO_CURL=1 NO_MMAP=1
$ make && make install
然后把生成的/home/hades/bin添加到系统环境中
$ echo "export PATH=/home/hades/bin:$PATH" >> ~/.bashrc
2.从本地拷贝一个空(bare)的repo出来
$ cd /home/hades
$ git-clone --bare software software.git
$ cd software.git/
$ git --bare update-server-info
$ chmod a+x hooks/post-update
$ touch git-daemon-export-ok
3.把这个software.git上传到DH主机上
$ scp -r software.git hades@montty.dreamhost.com:/example.com/path/software.git
4.回到本地的原始Git repo目录,提交改变到DH主机的repo上
$ git-push ssh://hades@montty.dreamhost.com/home/hades/example.com/path/software.git
如果你嫌反复输入这么长的操作命令的话
$ git remote add git-software \
ssh://hades@montty.dreamhost.com/home/hades/example.com/path/software.git
以后你只需要输入git-push git-software就行了
5.查看DH主机的repo
$ git-clone http://example.com/path/software.git
确认下DH主机上的repo是否已成功导入本地repo的内容及更新。
参考: