在 Linux 下搭建 Git 服务器(yum安装)

服务端(linux):

1. 安装git

[root@localhost ~]# yum -y install git      

2. 增加一个git账户

为了管理的方便,在linux下面增添一个 "git" 账户。
[root@localhost git]# useradd git

3.创建一个git远程仓库

[root@localhost home]# mkdir -p data/git/gittest.git
[root@localhost home]# git init --bare data/git/gittest.git
Initialized empty Git repository in /home/data/git/gittest.git/
[root@localhost home]# cd data/git/
[root@localhost git]# chown -R git:git gittest.git/
注意:此时远程仓库已经建好了,这个仓库不能直接提取文件,只能通过clone的方式从里面下载文件,不能直接拿来用
 
 

客户端(linux)

1.然后在客户端从 Linux Git 服务器上 clone 项目:

$ git clone git@192.168.56.101:/home/data/git/gittest.git

如果SSH用的不是默认的22端口,则需要使用以下的命令(假设SSH端口号是7700):

$ git clone ssh://git@192.168.56.101:7700/home/data/git/gittest.git

上面git clone需要输入密码登录:如果想免密登录,需要把公钥拷贝一下

2.配置免密登录

ssh-keygen -t rsa 生成密钥文件,在root下生成了.ssh目录

ssh-copy-id -i ~/.ssh/id_rsa.pub  git@192.168.25.133   #你需要免密登录的用户跟IP

 

 

客户端:(windows):

 参考文章:https://www.cnblogs.com/dee0912/p/5815267.html

 

 

posted @ 2018-06-13 11:44  天宇星空  阅读(384)  评论(0编辑  收藏  举报