服务器搭建 Git !!!

版权声明:[可爱的狼] https://blog.csdn.net/adorablewolf/article/details/88552912

1.安装git

yum install git

2.新建一个git用户

adduser git

3.新建一个.ssh的目录

mkdir /home/git/.ssh

4.在.ssh目录下新建authorized_keys文件,用来存放客户端的ssh_key

vi authorized_keys

5.创建你的git仓库  我的是: /data/git/lovelywolf

git init 项目名

6.设置所属组

chown -R git.git 项目名

chown -R git.git /home/git/.ssh/

7.打开RSA认证并

vi /etc/ssh/sshd_config

8.下面4个打开

PasswordAuthentication yes //开启密码登陆

RSAAuthentication yes

PubkeyAuthentication yes

AuthorizedKeysFile .ssh/authorized_keys

9.重启SSH服务

service sshd restart

10.权限问题

 版本库文件夹 权限必须是755

git文件夹 权限必须700

.ssh 下的 authorized_keys 权限必须是644

chmod -R 644 authorized_keys

所属用户组的问题: . 这个 所属用户组 必须是git

出现以下问题(解决方案):

# 设置允许远程接收文件(进入仓库)

git config receive.denyCurrentBranch ignore

在远程仓库,post-receive 钩子文件中添加自动更新工作目录内容 (vim 创建编辑)

WORK_TREE='../'
git  --work-tree="${WORK_TREE}" reset --hard

确保 post-receive 具有执行权限 755

git config --global core.autocrlf false

猜你喜欢

转载自blog.csdn.net/adorablewolf/article/details/88552912