## Git服务器搭建 csjs2-ws-gitrepos: 安装git ```shell yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel perl-devel -y yum install git -y ``` 创建用户 ```bash groupadd git useradd git -g git ``` 创建证书登陆 ```bash cd /home/git/ mkdir .ssh chmod 755 .ssh touch .ssh/authorized_keys chmod 644 .ssh/authorized_keys ``` 创建证书 ```bash chown -R git:git /home/git/ su git ssh-keygen -t rsa -C "邮箱" # 然后一路回车 cat /home/git/.ssh/id_rsa.pub >> /home/git/authorized_keys ``` 初始化git仓库 ```bash mkdir -p /data/repos cd /data/repos git init --bare csjs2_client_dev.git chown -R git:git /data/repos ``` git clone拉去仓库 ```bash mkdir -p /data/wwwroot chown -R git:git /data/wwwroot cd /data/wwwroot su git git clone ssh://[email protected]:2483/data/repos/csjs2_client_dev.git ``` 创建钩子文件post-receive ```bash su git cd /data/repos/csjs2_client_dev.git/hooks vim post-receive #!/bin/bash git --work-tree=/data/wwwroot/csjs2_client_dev checkout -f chmod +x post-receive ``` 部署完成以后你在任何地方上传csjs2_client_dev,本地的/data/wwwroot/csjs2_client_dev都会自动更新
==========git免密操作========
/home/git/.ssh/authorized_keys
添加你电脑的公钥 就可以免密了
========================
git init --bare lmdgh5_client_dev.git
git init --bare lmdgh5_client_release.git
git init --bare lmdgh5_server_dev.git
git init --bare lmdgh5_server_release.git
标签:git,自建,csjs2,dev,client,ssh,data,搭建 From: https://www.cnblogs.com/wusenwusen/p/16744398.html