搭建步骤
- 准备一台装有Linux的电脑,可以是笔记本、raspberry pi
- 安装ssh服务和git
- 配置git用户,限定用户权限
- 创建git仓库
为什么要搭GIT私服?
- 保密需要
- 非开源的代码
- 笔记,论文LaTeX源码
- 安全需要 即使github的付费用户,GIT私服也是需要的
- 多一份备份
- 减少宕机可能
- 备份本地分支(local branch)
- 无互联网场合
- 参加一些活动的时候,团队需要在没有互联网的情况下工作,如RoboCup
详细步骤
以ubuntu为例
# install ssh server and git sudo apt install openssh-server git # create git user sudo adduser git su git cd ## configure ssh mkdir .ssh && chmod 700 .ssh touch .ssh/authorized_keys && chmod 600 .ssh/authorized_keys ## append ssh public keys from your team members cat /tmp/id_rsa.yours.pub >> ~/.ssh/authorized_keys cat /tmp/id_rsa.others.pub >> ~/.ssh/authorized_keys # restrict ssh access cat /etc/shells # see if `git-shell` is already in there. If not... which git-shell # make sure git-shell is installed on your system. sudo nano /etc/shells # and add the path to git-shell from last command sudo chsh git # and enter the path to git-shell, usually: /usr/bin/git-shell # create git repo git init --bare project.git