前言
本篇blog主要说明的是如何将本地的项目代码通过git直接push到线上发布,未作更深的权限管理及linux的用户管理问题的考量。
服务端
安装Git
1 2
| $ yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel perl-devel $ yum install git
|
初始化Git仓库
以root用户及目录为例
1 2 3 4 5
| $ cd /root $ mkdir gittest $ cd gittest $ git init --bare test.git Initialized empty Git repository in /home/gitrepo/test.git/
|
git仓库与项目源码分离
1 2
| $ cd test.git/hooks $ vi post-receive
|
输入
1
| git --work-tree=/root/gittest --git-dir=/root/gittest/test.git checkout -f
|
/root/gittest #代码目录
/root/gittest/test.git #git库目录
文件权限
本地
1 2
| git clone root@ServerName:/root/gittest/test.git git push origin master
|
即可在服务端/root/gittest目录下查看到提交的文件, 把/root/gittest作为web目录, 即可.