git服务器搭建

By 肖奈
2018-09-05
4887 read

Git 服务器搭建


1、安装Git

$ yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel perl-devel
$ yum install git

接下来我们 创建一个git用户组和用户,用来运行git服务:

$ groupadd git
$ useradd git -g git

2、创建证书登录

收集所有需要登录的用户的公钥,公钥位于id_rsa.pub文件中,把我们的公钥导入到/home/git/.ssh/authorized_keys文件里,一行一个。

如果没有该文件创建它:

$ cd /home/git/$ mkdir .ssh
$ chmod 755 .ssh
$ touch .ssh/authorized_keys
$ chmod 644 .ssh/authorized_keys


3、初始化Git仓库

首先我们选定一个目录作为Git仓库,假定是/home/gitrepo/heanny.git,在/home/gitrepo目录下输入命令:

$ cd /home
$ mkdir gitrepo
$ chown git:git gitrepo/$ cd gitrepo

$ git init --bare heanny.git
Initialized empty Git repository in /home/gitrepo/heanny.git/

以上命令Git创建一个空仓库,服务器上的Git仓库通常都以.git结尾。然后,把仓库所属用户改为git:

$ chown -R git:git heanny.git

4、克隆仓库

$ git clone git@1.1.1.1:/home/gitrepo/heanny.git
Cloning into "heanny"...warning: You appear to have cloned an empty repository.
Checking connectivity... done.

1.1.1.1. 为 Git 所在服务器 ip ,你需要将其修改为你自己的 Git 服务 ip。

这样我们的 Git 服务器安装就完成。

Apache 配置https及强制使用443端口
Django自定义用于Views的装饰器

Comments

暂无评论,还不快来坐沙发...

Leave a Reply