首页 > 代码库 > Git服务器搭建及配置

Git服务器搭建及配置

一、部署环境

Server操作系统:CentOS release 6.7 (Final)

内核版本:2.6.32-358.el6.x86_64

git版本:1.9.0,源码下载地址如下

https://code.google.com/archive/p/git-core/downloads

二、安装及配置

1、安装依赖包

# yum -y install curl-devel expat-devel gettext-devel openssl-devel zlib-devel perl-devel

2、编译安装git

# tar xf git-1.9.0.tar.gz

# cd git-1.9.0

# make prefix=/usr/local all

# make prefix=/usr/local install

查看git版本号:

# git --version

git version 1.9.0

3、添加git用户

# useradd -s /bin/git-shell -c ‘git version control‘ git

# mkdir /home/git/.ssh

4、将客户端生成的秘钥上传到服务器上

# ssh-keygen 一路回车,然后将~/.ssh/id_rsa.pub放到服务器上

# scp ~/.ssh/id_rsa.pub root@192.168.1.203:/home/git/.ssh/authorized_keys

将/etc/ssh/ssh_config文件以下注释去掉:

RSAAuthentication yes

PubkeyAuthentication yes

AuthorizedKeysFile  .ssh/authorized_keys

5、创建一个git的裸仓库

# git init --bare fansik.git

# chown -R git.git  /home/git/

6、克隆远程仓库

# git clone git@192.168.1.203:/home/git/fansik.git

7、测试上传

进入到fansik目录

# vim fansik

# git add fansik

# git commit -m "fansik"

# git push -u origin master

Git服务器搭建及配置