Gitolite安装和配置

什么是GIT?

Git是一个开源的分布式版本控制系统,用以有效、高速的处理从很小到非常大的项目版本管理。

什么是Gitolite?

gitolite是git的权限控制系统。

Gitolite安装

环境: redhat

服务器:192.168.1.104

客户端:192.168.1.105

因为系统本身自带Git所以不用安装

如果没有

#wget https://www.kernel.org/pub/software/scm/git/git-2.2.0.tar.gz

创建Git用户

[root@localhost ~]# adduser  git

在git用户目录下安装gitolite

[root@localhost ~]# adduser  git

[root@localhost ~]# su - git

[git@localhost ~]$ cd

[git@localhost ~]$ mkdir bin

克隆gitolite源码

[git@localhost ~]$ git clone https://github.com/sitaramc/gitolite.git

[git@localhost ~]$ ls    查看

bin  gitolite

安装gitolite

[git@localhost ~]$ ./gitolite/install  --to /home/git/bin/

[git@localhost ~]$ ls bin/

commands  gitolite  gitolite-shell  lib  syntactic-sugar  triggers  VERSION  VREF

配置gitolite管理员

这里我们默认指定root用户为管理员

root@localhost ~]# ssh-keygen

[root@localhost ~]# cp .ssh/id_rsa.pub  /tmp/admin.pub

切换到git用户,为gitolite配置管理员

[git@localhost ~]$ 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)

[git@localhost ~]$ ls

bin  gitolite  projects.list  repositories

管理员日常管理 克隆库到本地

[root@localhost ~]# git clone git@192.168.1.104:gitolite-admin

Initialized empty Git repository in /root/gitolite-admin/.git/

Enter passphrase for key '/root/.ssh/id_rsa':

git@192.168.1.104's password:

remote: Counting objects: 6, done.

remote: Compressing objects: 100% (4/4), done.

Receiving objects: 100% (6/6), 755 bytes, done.

remote: Total 6 (delta 0), reused 0 (delta 0)

gitoadmin会生成两个目录文件

[root@localhost ~]# cd gitolite-admin/

[root@localhost gitolite-admin]# ls

conf  keydir

验证 :

创建库、添加用户

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

首先test用户向git服务器提交自己的公钥,传送到192.168.1.104/tmp目录下

客户端:

创建test账户并设置密码

[root@localhost ~]# adduser  test

[root@localhost ~]# passwd  test

更改用户 test 的密码 。

新的 密码:

重新输入新的 密码:

passwd: 所有的身份验证令牌已经成功更新。

创建公钥并复制到服务器上

[root@localhost ~]# su test

[test@localhost root]$ ssh-keygen

[root@localhost ~]# scp /home/test/.ssh/id_rsa.pub  root@192.168.1.104:/tmp

The authenticity of host '192.168.1.104 (192.168.1.104)' can't be established.

RSA key fingerprint is 2f:9e:72:d0:dd:cc:15:f6:af:51:0b:c3:30:e0:92:b0.

Are you sure you want to continue connecting (yes/no)? yes

Warning: Permanently added '192.168.1.104' (RSA) to the list of known hosts.

root@192.168.1.104's password:

id_rsa.pub                                                                                                   100%  408     0.4KB/s   00:00

服务器:

把公钥放到keydir目录下

[root@localhost tmp]# cp id_rsa.pub  /root/gitolite-admin/keydir/test.pub

[root@localhost keydir]# ls

admin.pub  test.pub

管理员创建mytest库,给test用户权限

[root@localhost conf]# pwd

/root/gitolite-admin/conf

[root@localhost conf]# vim gitolite.conf

定义mytest库,给指定用户权限

@mygroup        = test

repo mytest

RW+         =@mygroup

注释:mygroup是一个组。给这个组权限是读写推送的权限

查看git库状态

[root@localhost gitolite-admin]# git status

# On branch master

# Changed but not updated:

#   (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库

[root@localhost gitolite-admin]# git add keydir/test.pub  conf/gitolite.conf

[root@localhost gitolite-admin]# git status

# On branch master

# Changes to be committed:

#   (use "git reset HEAD <file>..." to unstage)

#

#modified:   conf/gitolite.conf

#new file:   keydir/test.pub

#  这里表示第一次执行git commit命令会有提示需要使用者标明身份·

[root@localhost gitolite-admin]# git commit -m "add repo mytest; add user test"

[master 73ef920] add repo mytest; add user test

Committer: root <root@localhost.localdomain>

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 you@example.com

If the identity used for this commit is wrong, you can fix it with:

git commit --amend --author='Your Name <you@example.com>'

2 files changed, 4 insertions(+), 0 deletions(-)

create mode 100644 keydir/test.pub

创建用户和邮箱

[root@localhost gitolite-admin]# git config --global user.email "xiaohu@qq.com"

[root@localhost gitolite-admin]# git config --global user.name  "xiaohu"

执行完之后修改的文件只是推送到本地了,但是没推送到服务器上,还需要执行git push

[root@localhost gitolite-admin]# git push origin master

Enter passphrase for key '/root/.ssh/id_rsa':

git@192.168.1.104's password:

Counting objects: 10, done.

Compressing objects: 100% (5/5), done.

Writing objects: 100% (6/6), 832 bytes, done.

Total 6 (delta 0), reused 0 (delta 0)

remote: Initialized empty Git repository in /home/git/repositories/mytest.git/

To git@192.168.1.104:gitolite-admin

8a1974d..73ef920  master -> master

客户端验证

[root@localhost ~]#  git clone git@192.168.1.104:/home/git/repositories/mytest.git

Initialized empty Git repository in /root/mytest/.git/

git@192.168.1.104's password:

warning: You appear to have cloned an empty repository.

验证成功

查看

[root@localhost ~]# ls

anaconda-ks.cfg  install.log  install.log.syslog  mysql-cluster-gpl-7.4.6-linux-glibc2.5-i686.tar.gz  mytest

创建一个文件添加到git

[root@localhost mytest]# git add 1.txt

[root@localhost mytest]# git commit "add file 1.txt"

[root@localhost mytest]# git commit -m "add file 1.txt"

[master (root-commit) f7b7637] add file 1.txt

Committer: root <root@localhost.localdomain>

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 you@example.com

If the identity used for this commit is wrong, you can fix it with:

git commit --amend --author='Your Name <you@example.com>'

0 files changed, 0 insertions(+), 0 deletions(-)

create mode 100644 1.txt

创建邮箱和用户

[root@localhost mytest]# git config --global user.email xiaohu@qq.com

[root@localhost mytest]# git config --global user.name test

提交文档到分支查看

[root@localhost mytest]# git commit -m "add file 1.txt"

# On branch master

nothing to commit (working directory clean)

[root@localhost mytest]# git status

# On branch master

nothing to commit (working directory clean)

转载于:https://blog.51cto.com/10966380/1767313

Gitolite使用相关推荐

  1. CentOS6.*安装gitolite

    2019独角兽企业重金招聘Python工程师标准>>> CentOS6.*安装gitolite 安装基础包 # yum install perl openssh git 创建git用 ...

  2. 使用tortoise git管理gitolite版本库

    gitolite-admin是用于管理git版本库的版本库,将其从服务器上clone下来. 使用tortoise git clone的时候需要指定私钥,私钥的格式是ppk的,需要使用putty的PUT ...

  3. gitolite搭建

    简单流程 <!--添加用户--> useradd git useradd gitadmin su git<!--下载gitolite--> mkdir -p $HOME/bin ...

  4. 基于Gitolite的Git服务架设

    如果不是要与他人协同开发,git根本不需要架设服务器,git可以直接使用本地版本库的路径完成git版本间的操作.但是如果需要和他人分享版本库,协作开发,就需要能够通过网络协议操作git库.git支持的 ...

  5. CentOS 7下使用Gitolite搭建Git私服

    1. 搭建环境 CentOS7, git version 1.8.3.1 2. 安装依赖包 yum install curl-devel expat-devel gettext-devel opens ...

  6. CentOS 6.7 Gitolite 服务搭建及TortoiseGit配置连接

    咳咳~好几天没写博文啦,这几天都在研究Git,没办法公司要要抛弃SVN转站Git,废话就不多说,下面我们进行操作演示: 环境:之前搭建的Redis-Master服务器一枚,配置一般般~ 工具:Tort ...

  7. 怎样在Ubuntu 14.04中搭建gitolite git服务器

     1.   首先这里我们安装openssh-serveropenssh-client,如果你用的是VPS之类的一般都默认安装好了,不过运行一个这个命令不会有错的,如果有安装就会提示已安装. sud ...

  8. gitolite 踩坑记

    为什么80%的码农都做不了架构师?>>>    加入.pub 文件后,不生成authorized_keys的问题,请执行: gitolite setup ,详细分析见https:// ...

  9. 使用Gitolite搭建Gitserver

    Gitolite是一款Perl语言开发的Git服务管理工具.通过公钥对用户进行认证.并可以通过配置文件对些操作进行基于分支和路径的精细控制. Gitolite採用的是SSH协议而且使用SSH公钥认证. ...

  10. ubuntu Gitolite管理git server代码库权限

    公司代码库用Git,全部用SSH认证,多个代码库多个用户,权限管理是个头疼的问题,今天终于有空测试下Gitolite, Gitolite是在Git之上的一个授权层,依托sshd或者httpd来进行认证 ...

最新文章

  1. c# 自定义控件使其填充方格且自动变换大小
  2. Sklearn 损失函数如何应用到_Sklearn全复习(下)(持续更新)
  3. java scriptrunner_ScriptRunner.java
  4. 如何通过信息系统项目管理师+中级备考经验
  5. 计算机网络(谢希仁第八版)第三章:数据链路层
  6. opengl 安装_如何使得支持 OpenGL 的 Flatpak 应用和游戏在专有 Nvidia 图形驱动下工作 | Linux 中国...
  7. 强化学习ppt_强化学习和最优控制的十个关键点81页PPT汇总
  8. Spark Shuffle系列-----1. Spark Shuffle与任务调度之间的关系
  9. UNICODE_STRING__ZC
  10. 人脸方向学习(二十一):Face Landmark Detection-FAB-解读
  11. 我花 10 个小时,写出了小白也能看懂的阿里数据中台分析!
  12. 如何在WPS2000中插入AutoCad图形文件(转)
  13. 树形DP-Bribing FIPA
  14. 天朝理工学院SQL脚本
  15. ITX迷你主机的优点及缺点
  16. ROS自主驾驶割草机
  17. 古代地图的那些趣事儿
  18. 前端技术学习:语义化
  19. 隐私公链Findora全景观察
  20. UE4中使用第三方库Ⅱ

热门文章

  1. lvs负载均衡+keepalive高可用
  2. 苏永康曝郑秀文许志安秘婚 红包印“许”字
  3. 内联网、外联网、互联网,你晓得几个
  4. Android|Toast理论篇(附自制图标信息框实现)
  5. C语言sizeof和strlen的区别
  6. Linux安装Chrome和chromedriver进行截图
  7. 常见的开源分布式存储系统
  8. 网络编程基础DAY2:TCP和UDP
  9. Google 中文名发布 | 历史上的今天
  10. HandyJSON库简介