1.一、初始化Git仓库
首先咱们选定一个目录做为Git仓库,假定是/home/data/share/share.git,在/home/data/目录下输入命令:nginx
$ cd /home/data/ $ mkdir share $ chown git:git share/ $ cd share $ git init --bare share.git Initialized empty Git repository in /home/data/share/share.git/
以上命令Git建立一个空仓库,服务器上的Git仓库一般都以.git结尾。而后,把仓库所属用户改成git:git
$ chown -R git:git share.git
1.2 配置自动同步web
$ cd /home/data/share/share.git/hooks vim post-receive #!/bin/bash git --work-tree=/web/share checkout -f chmod -R 777 post-receive
1.3检出代码,到nginx指定的项目目录vim
cd /web git clone /home/data/share/share.git/ chmod -R 777 share
Windows客户端: bash
git clone git@39.107.77.206:/home/data/share/share.git