Git 服务器搭建,如果无需权限控制,仅团队内部使用,初始化一个服务器仓库,其他人通过 ssh 访问这个文件夹即可。具体步骤如下:
- 添加 git-shell
which git-shell
vim /etc/shells # and add the path to git-shell from last command
- 添加 Git 用户
useradd git -m -s git-shell
- 初始化仓库
mkdir -p /opt/git/repo.git
git init --bare /opt/git/repo.git
chown -R git:git /opt/git
- 定制欢迎信息
git help shell
vim /home/git/git-shell-commands/no-interactive-login
---
#!/bin/sh
printf '%s\n' "Hi $USER! You've successfully authenticated, but I do not"
printf '%s\n' "provide interactive shell access."
exit 128
- 验证配置结果
ssh -T git@ip
---
Hi git! You've successfully authenticated, but I do not
provide interactive shell access.
- Clone 仓库
git clone git@git-server:/opt/git/repo.git
参考:https://git-scm.com/book/zh/v2 - 服务器上的git