分几个步骤 git
建立裸版本库: web
[root@localhost]$ mkdir /home/workspace [root@localhost]$ cd /home/workspace [root@localhost]$ git init -bare wwwroot.git
建立web目录: shell
[root@localhost]$ mkdir -p /home/website/wwwroot
[root@admin.pc]$ cd e: [root@admin.pc]$ git init local.git
[root@admin.pc e:/local.git/]$ git clone ssh://root@xxx.xxx.x/home/workspace/wwwroot.git
设置钩子 bash
[root@localhost]$ cd /home/workspace/wwwroot.git/hooks [root@localhost]$ cat > post-receive <<EOF >#!/bin/bash >git --work-tree=/home/website/wwwroot checkout -f >EOF [root@localhost]$ chmod +x post-receive
而后就能够开始从本地开发了,在本地版本库工做区里开发,而后使用git push指令推送到远程裸版本库,钩子会post-receive自动生效,将文件检出到--work-tree目录里,实现同步。 服务器
第一次push可能会有一些提示,由于裸版本库还什么都没有,你可能须要 git push origin master写全命令,以后就不必了。 ssh