在linux上搭建GIT服务器

1、创建一个linux用户

1
adduser git

2、切换到git用户

1
su git

3、创建该git用户的秘钥

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
git@MC-PC1:~$ pwd
/home/git

# 创建秘钥
ssh-keygen -o

# 将公钥秘钥移到目录下面
touch .ssh/id_rsa.pub >> authorized_keys

# 结果如下
ll .ssh
drwx------ 2 git git 4096 May 13 17:18 ./
drwxr-xr-x 3 git git 4096 May 13 17:11 ../
-rw------- 1 git git 564 May 13 17:19 authorized_keys
-rw------- 1 git git 2590 May 13 17:12 id_rsa
-rw-r--r-- 1 git git 564 May 13 17:12 id_rsa.pub

4、创建Git项目

1
2
3
# 创建Git目录
mkdir /mnt/e/phpstudy_pro/www/shidao-dms.git
git init --bare

报错:

git@MC-PC1:/mnt/e/phpstudy_pro/www/shidao-dms.git$ git init –bare
error: chmod on /mnt/e/phpstudy_pro/www/shidao-dms.git/config.lock failed: Operation not permitted
fatal: could not set ‘core.filemode’ to ‘false’

解决:

根据这个链接操作后,无效,不过还是值得一试。http://www.lvesu.com/blog/main/cms-821.html