初始化git库并配置自动部署

时间:2021-08-16 19:51:29

1.初始化库

git init --bare wap.git

2.配置wap.git/config文件

[core]
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
        ignorecase = true
        precomposeunicode = true
        worktree = /data1/project/admin
[receive]
        denycurrentbranch = ignore

3.新建钩子wap.git/hooks/post-receive

#!/bin/bash

echo "===> start to Synchronization code"
git --work-tree=/data1/project/wap checkout -f

4.把新建的wap.git赋予全部权限为git用户账号

chown git.git wap.git/ -R

5.新建部署代码的目录并赋予git用户账号权限

mkdir /data1/project/wap
chown git.git /data1/project/wap/

6.使用git用户账号@url:wap.git即可clone项目

git clone git用户账号@url:wap.git