搭建自建git仓库
## 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://git@172.16.0.161: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 _client_dev.git
git init --bare _client_release.git
git init --bare _server_dev.git
git init --bare server_release.git
-------------如果没有公钥---------------
ssh-keygen
#不要乱执行这个啊 会把公钥私钥换了
chown git.git * -R
-----------------------------------------------------------------------------------------------------------------------------------------