CentOS 6.4x64安装git和gitolite服务器

一.部署环境

系统:CentOS 6.4x64 最小化安装

IP:192.168.3.27

二.安装基础依赖包

[[email protected] ~]#yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel perl-devel -y

三.下载git-2.2.0.tar.gz

[[email protected] ~]#wget https://www.kernel.org/pub/software/scm/git/git-2.2.0.tar.gz

四.解压文件到当前目录下,并安装

[[email protected] git-2.2.0]#tar xf git-2.2.0.tar.gz
[[email protected] git-2.2.0]#cd  git-2.2.0/
[[email protected] git-2.2.0]#make prefix=/usr/local/git all
[[email protected] git-2.2.0]#make prefix=/usr/local/git install

增加软连接
[[email protected] git-2.2.0]#ln -s /usr/local/git/bin/* /usr/bin/

验证结果,显示出版本号,表示安装成功
[[email protected] git-2.2.0]#git --version
git version 2.2.0

五.创建git用户

[[email protected] ~]# useradd git

六.在git用户家目录下安装gitolite

[[email protected] ~]# su git
[[email protected] root]$ cd
[[email protected] ~]$ mkdir bin

七.克隆gitolite源码

[[email protected] ~]$ git clone https://github.com/sitaramc/gitolite.git 
Cloning into ‘gitolite‘...remote: Counting objects: 8884, done.
remote: Total 8884 (delta 0), reused 0 (delta 0), pack-reused 8884Receiving 
objects: 100% (8884/8884), 3.66 MiB | 179.00 KiB/s, done.
Resolving deltas: 100% (5055/5055), done.Checking connectivity... done.
[[email protected] ~]$ ls
bin  gitolite

八.安装gitolite

[[email protected] ~]$ ./gitolite/install --to /home/git/bin/
[[email protected] ~]$ ls bin/
commands  gitolite  gitolite-shell  lib  syntactic-sugar  triggers  VERSION  VREF

九.配置gitolite管理员

生成管理员账户的公钥(此处指定本地root用户为管理员,键入回车使用默认值)

[[email protected] ~]# ssh-keygen 
[[email protected] ~]# cp .ssh/id_rsa.pub /tmp/admin.pub

切换回git用户,为gitolite配置管理员 
[[email protected] ~]$ bin/gitolite setup -pk /tmp/admin.pub 
Initialized empty Git repository in /home/git/repositories/gitolite-admin.git
/Initialized empty Git repository in /home/git/repositories/testing.git/
WARNING: /home/git/.ssh missing; creating a new one    
(this is normal on a brand new install)
WARNING: /home/git/.ssh/authorized_keys missing; creating a new one    
(this is normal on a brand new install)

[[email protected] ~]$ ls
bin  gitolite  projects.list  repositories

十.管理员日常管理

[[email protected] ~]# git clone [email protected]:gitolite-admin
Cloning into ‘gitolite-admin‘...The authenticity of host 
‘192.168.3.27 (192.168.3.27)‘ can‘t be established.
RSA key fingerprint is c4:34:02:55:ad:42:8a:65:ba:94:00:20:48:d7:3c:33.
Are you sure you want to continue connecting (yes/no)? yes
#这里是第一次连接,需要输入yes进行确认
Warning: Permanently added ‘192.168.3.27‘ (RSA) to the list of known hosts.
remote: Counting objects: 6, done.
remote: Compressing objects: 100% (4/4), done.
Receiving objects: 100% (6/6), 734 bytes | 0 bytes/s, done.
remote: Total 6 (delta 0), reused 0 (delta 0)
Checking connectivity... done.

[[email protected] gitolite-admin]# ls
conf  keydir
[[email protected] gitolite-admin]# pwd
/root/gitolite-admin

验证:

创建库、添加用户

例如某test用户访问git服务器上的mytest库

test用户向git服务器管理(此处是之前的服务器本地的root用户)提交自己的ssh无密码公钥

管理员将test的公钥复制到 gitolite-admin/keydir/ 下

注:该key需要在test用户机器上使用ssh-keygen生成,再传送到192.168.3.27/tmp目录下

[[email protected] ~]# cp /tmp/test.pub /root/gitolite-admin/keydir/

管理员创建myFirstRepo库,并给test分配权限

[[email protected] ~]# cd gitolite-admin/conf/
[[email protected] conf]# vim gitolite.conf 
#以下是gitolite.conf的默认内容
repo gitolite-admin    
    RW+     =   admin
repo testing    
    RW+     =   @all
    
下边定义mytest库,并且指定用户权限:
#在gitolite.conf中添加以下内容
@mygroup    = test
repo mytest    
    RW+     = @mygroup
注:此处@mygroup是一个组,给mygroup组赋予对mytest这个库的读、写、推送的权限
(详细规则可参考gitolite的readme.txt)管理员将对gitolite-admin的修改(建库、加用户)
提交到git服务器

[[email protected] gitolite-admin]# pwd
/root/gitolite-admin
[[email protected] gitolite-admin]# git status    #查看git库状态
On branch master
Your branch is up-to-date with ‘origin/master‘.
Changes not staged for commit:  
(use "git add <file>..." to update what will be committed)  
(use "git checkout -- <file>..." to discard changes in working directory)	

    modified:   conf/gitolite.conf        #表示该文件被修改
Untracked files:  (use "git add <file>..." to include in what will be committed)
    keydir/test.pub        #增加的文件
no changes added to commit (use "git add" and/or "git commit -a")

#将有改动的文件添加到git库
[[email protected] gitolite-admin]# git add keydir/test.pub conf/gitolite.conf 
[[email protected] gitolite-admin]# git status
On branch master
Your branch is up-to-date with ‘origin/master‘.
Changes to be committed:  (use "git reset HEAD <file>..." to unstage)
    modified:   conf/gitolite.conf
    new file:   keydir/test.pub  
    #这里表示已添加#在第一次执行git commit命令时会有以下提示,需要使用者表明身份

[[email protected] gitolite-admin]# git commit -m "add repo mytest; add user test"
*** Please tell me who you are.Run  
    git config --global user.email "[email protected]"  
    git config --global user.name "Your Name"to set your account‘s default identity.
Omit --global to set the identity only in this repository.
fatal: unable to auto-detect email address (got ‘[email protected](none)‘)

#在这里我们执行以下2条命令
[[email protected] gitolite-admin]# git config --global user.email "[email protected]"
[[email protected] gitolite-admin]# git config --global user.name "lyao"

#再重新执行git commit命令
[[email protected] gitolite-admin]# git commit -m "add repo mytest; add user test"
[master 7b877e7] add repo mytest; 
add user test 2 files changed, 5 insertions(+) 
create mode 100644 keydir/test.pub

#执行完以上命令后,修改的文件只是提交在本地了,并没有提交到git server中,还需要执行git push命令
[[email protected] gitolite-admin]# git push origin master    #推送到远端的master分支
Counting objects: 6, done.Compressing objects: 100% (5/5), done.
Writing objects: 100% (6/6), 817 bytes | 0 bytes/s, done.
Total 6 (delta 0), reused 0 (delta 0)
remote: Initialized empty Git repository in /home/git/repositories/mytest.git
/To [email protected]:gitolite-admin   
3554f3d..7b877e7  master -> master

客户端验证:

[[email protected] ~]# git clone [email protected]:/mytest.git
Initialized empty Git repository in /root/mytest/.git/
warning: You appear to have cloned an empty repository.
[[email protected] ~]# ll
total 3240
drwxr-xr-x 3 root root    4096 Apr 17 14:45 mytest
[[email protected] ~]# cd mytest/
[[email protected] mytest]# git status
# On branch master#
# Initial commit
#nothing to commit (create/copy files and use "git add" to track)

#创建1个文件1.txt并添加到git
[[email protected] mytest]# touch 1.txt
[[email protected] mytest]# git add 1.txt 
[[email protected] mytest]# git commit "add file 1.txt"

#第一次使用需要表明身份
[[email protected] mytest]# git commit -m "add file 1.txt"
[master (root-commit) 08e9a37] add file 1.txt 
Committer: root <[email protected](none)>
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly:    
    git config --global user.name "Your Name"    
    git config --global user.email [email protected]
If the identity used for this commit is wrong, you can fix it with: 
   git commit --amend --author=‘Your Name <[email protected]>‘
    0 files changed, 0 insertions(+), 0 deletions(-) 
    create mode 100644 1.txt

[[email protected] mytest]# git config --global user.email [email protected]
[[email protected] mytest]# git config --global user.name test

[[email protected] mytest]# git commit -m "add file 1.txt"
# On branch masternothing to commit (working directory clean)

[[email protected] mytest]# git status
# On branch masternothing to commit (working directory clean)

[[email protected] mytest]# ll
total 0-rw-r--r-- 1 root root 0 Apr 17 14:47 1.txt

[[email protected] mytest]# git push origin master
Counting objects: 3, done.Writing objects: 100% (3/3), 206 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)To [email protected]:/mytest.git
 * [new branch]      master -> master
时间: 2024-07-29 17:38:54

CentOS 6.4x64安装git和gitolite服务器的相关文章

centos 6.4x64安装部署nagios

本文参考了http://wangzan18.blog.51cto.com/8021085/1628984 http://linuxnote.blog.51cto.com/9876511/1637773 一.nagios概述 Nagios是插件式的结构,它本身没有任何监控功能,所有的监控都是通过插件进行的,因此其是高度模块化和富于弹性的.Nagios监控的对象可分为两类:主机和服务.主机通常指的是物理主机,如服务器.路由器.工作站和打印机等,这里的主机也可以是虚拟设备,如xen虚拟出的Linux系

centos 6.4x64 安装gitlab

gitlab是一个使用 Ruby on Rails 开发的开源应用程序,与Github类似,能够浏览源代码,管理缺陷和注释,非常适合在团队内部使用. 一.环境 系统:CentOS 6.4x64最小化安装 IP:192.168.3.71 二.安装yum源 安装epel源 [[email protected] ~]# rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm Retrievin

CentOS 6 编译安装Git 2.8.1

环境介绍: 系统版本:CentOS 6.4 软件仓库:yum-Base,yum-Epel Git版本:git 2.8.1 安装方式:源码编译 删除原yum源中的git 1.7版本 # yum remove git -y 2. 安装依赖环境 # yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel gcc perl-ExtUtils-MakeMaker # yum install asciidoc xml

CentOS 6.4x64安装部署zabbix-2.4.5

以下内容来自于http://www.iyunv.com/thread-62087-1-1.html 补充一点,按照原文安装万之后zabbix页面会提示 zabbix server is not running: the information displayed may not be current 解决方法(参考自http://fengzhige.blog.51cto.com/3691377/1034485)是: setsebool -P httpd_can_network_connect o

CentOS 6.4x64安装部署zabbix

一.部署环境 系统:CentOS 6.4x64 最小化安装 Server:192.168.3.28 Client:192.168.3.29 二.基础软件包安装 在server安装基础软件包,这里的环境使用yum安装,如果使用源码安装也是可以的. [[email protected] ~]# yum -y install wget vim tree gcc gcc-c++ autoconf httpd php mysql mysql-server php-mysql httpd-manual mo

linux(centos)源码安装git

最近使用一个开源库,部署的的时候需要用git克隆依赖库.刚好系统没安装git.就尝试了源码安装git. 源码下载地址:http://codemonkey.org.uk/projects/git-snapshots/git/ 找了个最新版本的下载,我下载的是:git-latest.tar.xz 这个后缀的文件在我的linux系统不能解压.不想再安装相应的解压工具了.就机智地放在window下用winrar解压了. 上传到linux.修改git源码文件权限:chmod -R 755 git-2015

(转)【IPSEC】CentOS/Ubuntu一键安装IPSEC/IKEV2 VPN服务器

转载自quericy的博客(https://quericy.me) 花了点时间将上次的Ubuntu.CentOS搭建IPSec/IKEv2 VPN服务器全攻略整理成了一份一键安装的脚本.适用于WindowsPhone,iOS,Android和PC设备.有需要的童鞋可以拿来食用~ ~ ~ ~ CetnOS测试了下貌似没什么问题,Ubuntu的手里暂时没有空闲vps就没试了,其实也差不多的,欢迎测试和反馈 最新更新内容请见Github上的项目说明:https://github.com/quericy

CentOS 6.6安装LAMP和Subversion服务器

目标:在CentOS 6.6上安装LAMP,并安装最新版1.8.*的Subversion服务器,和Subversion权限管理前端iF.svnadmin. 安装步骤: 安装新一些版本LAMP步骤 1. 配置防火墙,开启80端口.3306端口 vi /etc/sysconfig/iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT -A INPUT -m state --state NEW -m tcp

CENTOS/UBUNTU一键安装IPSEC/IKEV2 VPN服务器

1.在azure上创建ubuntu虚拟机 选择v15.04 server 版本 2.添加端口号 3.远程桌面到ubuntu 命令行 输入 sudo su  输入创建 ubuntu虚拟机 时候的 密码 切换到root身份. 4.开始创建 ipsec/ikev2 vpn 服务器 [注] 我选择的是  Xen.KVM 的vps类型 [注]修改后 文件 不生效 则重新启动虚拟机 [注]win7客户端连接vpn 需要证书安装到  计算机账户的 受信任的根证书颁发机构 具体如下:1.下载脚本: wget h