Linux上搭建GIT

作者: 村长王无敌 | 来源:发表于2020-05-12 11:10 被阅读0次

1、安装GIT

yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel perl-devel

yum install git

2、创建git用户组和用户,设置git用户密码

groupadd git

useradd git -g git

passwd git

3、创建证书登录

cd /home/git/

mkdir .ssh

chmod 755 .ssh

touch .ssh/authorized_keys

chmod 644 .ssh/authorized_keys

4、创建仓库,选定目录作为仓库目录,如/home/project.git

cd /home

git init --bare project.git

Initialized empty Git repository in /home/project.git/

5、把仓库所属用户改为git

chown -R git:git runoob.git

6、利用git钩子同步服务器代码

进入钩子目录cd /home/project.git/hooks

编辑post-receive文件,在post-receive文件输入以下内容:

#!/bin/bash

  git --work-tree=/var/www checkout -f

7、尝试push代码上服务器,如果push成功但是在/var/www目录下看不到push的文件,说明git用户没有/var/www的权限:

chown git:git post-receive

chmod 744 post-receive

相关文章

网友评论

    本文标题:Linux上搭建GIT

    本文链接:https://www.haomeiwen.com/subject/cszvnhtx.html