Table of Contents
平台
- FreeBSD 12.0 64位
搭建GIT服务器
服务端安装git
cd /usr/ports/devel/git
make install clean
创建管理用户
# adduser
Username: git
Full name: git
Uid (Leave empty for default):
Login group [git]:
Login group is git. Invite git into other groups? []:
Login class [default]:
Shell (sh csh tcsh git-shell nologin) [sh]:
Home directory [/home/git]:
Home directory permissions (Leave empty for default):
Use password-based authentication? [yes]:
Use an empty password? (yes/no) [no]:
Use a random password? (yes/no) [no]:
Enter password:
Enter password again:
Lock out the account after creation? [no]:
Username : git
Password : *****
Full Name : git
Uid : 1002
Class :
Groups : git
Home : /home/git
Home Mode :
Shell : /bin/sh
Locked : no
OK? (yes/no): yes
adduser: INFO: Successfully added (git) to the user database.
Add another user? (yes/no): no
Goodbye!
创建证书登录
将需要登录git服务器的用户的公钥,以追加的方式写入~/.ssh/authorized_keys
初始化Git仓库
在git家目录创建一个backup.git目录,然后初始化为裸仓库
mkdir backup.git
git init --bare backup.git
禁用shell登录
出于安全考虑,git管理用户不允许登录shell。
编辑/etc/passwd,使git用户可以正常通过ssh使用git,但无法登录shell。
git:*:1003:1003:git:/home/git:/bin/sh
修改为
git:*:1003:1003:git:/home/git:/usr/local/bin/git-shell
搭建客户端
windows搭建
-
下载Git for Windows
地址:https://gitforwindows.org/ -
emacs magit
M-x package-install magit
参考:http://jixiuf.github.io/blog/000100-emacs-magit.html/#sec-5
问题
pw: user 'username' disappeared during update
解决
/usr/sbin/pwd_mkdb -p /etc/master.passwd
refusing to update checked out branch: refs/heads/master
解决
修改.git/config文件,增加
[receive]
denyCurrentBranch = ignore
作者:混吃等死
-------------------------------------------
个性签名:混吃等死
-------------------------------------------
日常总结,均为原创,欢迎交流,转载请注明