首页 > 系统相关 >git: centos stream9上安装gitolite

git: centos stream9上安装gitolite

时间:2024-07-16 09:41:15浏览次数:10  
标签:git centos hint blog gitolite master root stream9

一,关于gitolite

1,官网:

https://gitolite.com/gitolite/index.html

2,代码网站:

https://github.com/sitaramc/gitolite

3,说明:

3个角色: git服务器,上面运行gitolite/ssh服务
            管理服务器:用来管理项目,这里我们和git服务器用同一台机器
             客户端:  使用git客户端

二,安装gitolite的准备工作

1,安装git:git服务器

[root@blog ~]# yum install git

 查看git的版本:

[root@blog ~]# git --version
git version 2.43.5

2,安装perl: git服务器

[root@blog ~]# yum install perl

查看perl的版本

[root@blog ~]# perl --version

3,添加git用户:git服务器

[root@blog ~]# groupadd git
[root@blog ~]# useradd -m git -g git

设置密码:

[root@blog ~]# passwd git
Changing password for user git.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.

4,生成密钥,过程中无需输入密码,一路回车即可:管理服务器

[root@blog ~]# ssh-keygen
Generating public/private rsa key pair.
...

保存公钥

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

三,安装gitolite

1, 切换到git账号: git服务器

[root@blog ~]# su git
[git@blog root]$ cd
[git@blog ~]$ 

创建bin目录

[git@blog ~]$ mkdir bin
[git@blog ~]$ ls
bin

2,下载源码:git服务器

[git@blog ~]$ git clone https://github.com/sitaramc/gitolite.git
Cloning into 'gitolite'...
remote: Enumerating objects: 9791, done.
remote: Counting objects: 100% (85/85), done.
remote: Compressing objects: 100% (58/58), done.
remote: Total 9791 (delta 24), reused 58 (delta 17), pack-reused 9706
Receiving objects: 100% (9791/9791), 3.09 MiB | 3.76 MiB/s, done.
Resolving deltas: 100% (6050/6050), done.
[git@blog ~]$ ls
bin  gitolite

3,安装:git服务器

准备安装,把gitolite的安装文件指向bin 

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

安装:

[git@blog ~]$ /home/git/bin/gitolite setup -pk /tmp/admin.pub
hint: Using 'master' as the name for the initial branch. This default branch name
hint: is subject to change. To configure the initial branch name to use in all
hint: of your new repositories, which will suppress this warning, call:
hint:
hint:   git config --global init.defaultBranch <name>
hint:
hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
hint: 'development'. The just-created branch can be renamed via this command:
hint:
hint:   git branch -m <name>
Initialized empty Git repository in /home/git/repositories/gitolite-admin.git/
hint: Using 'master' as the name for the initial branch. This default branch name
hint: is subject to change. To configure the initial branch name to use in all
hint: of your new repositories, which will suppress this warning, call:
hint:
hint:   git config --global init.defaultBranch <name>
hint:
hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
hint: 'development'. The just-created branch can be renamed via this command:
hint:
hint:   git branch -m <name>
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@blog ~]$ ls
bin  gitolite  projects.list  repositories

查看创建的库:

[git@blog ~]$ ls repositories/
gitolite-admin.git  testing.git

默认创建了testing仓库和gitolite-admin仓库,
testing是用于测试
gitolite-admin是用于权限配置

四,管理端克隆管理项目(本例中和服务端同一台机器)

1,克隆管理项目:管理服务器

[root@blog gitadmin]# git clone ssh://git@localhost:22/gitolite-admin
Cloning into 'gitolite-admin'...
The authenticity of host '[localhost]:22 ([127.0.0.1]:22)' can't be established.
ED25519 key fingerprint is SHA256:cTfZOVKLpUrtlhnXaD9GdXBrohdB7Y9VKN7RmRI9kTc.
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '[localhost]:22' (ED25519) to the list of known hosts.
remote: Enumerating objects: 6, done.
remote: Counting objects: 100% (6/6), done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 6 (delta 0), reused 0 (delta 0), pack-reused 0
Receiving objects: 100% (6/6), done.

可以看到它的目录结构:

[root@blog gitolite-admin]# ls
conf  keydir

conf下是配置文件,

keydir是存放用户公钥的目录

2,添加一个用户:

客户端:创建密钥

liuhongdi@lhdpc:~$ ssh-keygen 
Generating public/private rsa key pair.
Enter file in which to save the key (/home/liuhongdi/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/liuhongdi/.ssh/id_rsa
Your public key has been saved in /home/liuhongdi/.ssh/id_rsa.pub
...

把公钥上传到管理项目所在目录

然后提交新用户公钥到gitolite-admin项目中

[root@blog gitolite-admin]# git add -A
[root@blog gitolite-admin]# git commit -m "add user liuhongdi";
[master 957bfaf] add user liuhongdi
 1 file changed, 1 insertion(+)
 create mode 100644 keydir/liuhongdi.pub
[root@blog gitolite-admin]# git push origin master
Enumerating objects: 6, done.
Counting objects: 100% (6/6), done.
Delta compression using up to 8 threads
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 801 bytes | 801.00 KiB/s, done.
Total 4 (delta 0), reused 0 (delta 0), pack-reused 0
To ssh://localhost:22/gitolite-admin
   794ac5e..957bfaf  master -> master

3, 新建一个项目并提交:管理服务器

[root@blog gitolite-admin]# cd conf/
[root@blog conf]# ls
gitolite.conf
[root@blog conf]# vi gitolite.conf

修改后内容:

repo gitolite-admin
    RW+     =   admin

repo testing
    RW+     =   @all

@gsGroup=admin  liuhongdi
repo gsapi
    RW+ =   @gsGroup

 提交

[root@blog conf]# git status
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 restore <file>..." to discard changes in working directory)
        modified:   gitolite.conf

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        .gitolite.conf.swp

no changes added to commit (use "git add" and/or "git commit -a")
[root@blog conf]# rm .gitolite.conf.swp
rm: remove regular file '.gitolite.conf.swp'? y
[root@blog conf]# git status
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 restore <file>..." to discard changes in working directory)
        modified:   gitolite.conf

no changes added to commit (use "git add" and/or "git commit -a")
[root@blog conf]# git add -A
[root@blog conf]# git commit -m "add repo gsapi";
[master affb07b] add repo gsapi
 1 file changed, 5 insertions(+)
[root@blog conf]# git status
On branch master
Your branch is ahead of 'origin/master' by 1 commit.
  (use "git push" to publish your local commits)

nothing to commit, working tree clean
[root@blog conf]# git push origin master
Enumerating objects: 7, done.
Counting objects: 100% (7/7), done.
Delta compression using up to 8 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (4/4), 397 bytes | 397.00 KiB/s, done.
Total 4 (delta 0), reused 0 (delta 0), pack-reused 0
remote: hint: Using 'master' as the name for the initial branch. This default branch name
remote: hint: is subject to change. To configure the initial branch name to use in all
remote: hint: of your new repositories, which will suppress this warning, call:
remote: hint:
remote: hint:   git config --global init.defaultBranch <name>
remote: hint:
remote: hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
remote: hint: 'development'. The just-created branch can be renamed via this command:
remote: hint:
remote: hint:   git branch -m <name>
remote: Initialized empty Git repository in /home/git/repositories/gsapi.git/
To ssh://localhost:22/gitolite-admin
   957bfaf..affb07b  master -> master

五,客户端配置项目

下载新项目:

新项目为空,所以提示是空仓库

liuhongdi@lhdpc:~/work/gsapi$ git clone ssh://[email protected]:22/gsapi
正克隆到 'gsapi'...
warning: 您似乎克隆了一个空仓库

提交修改等功能也可以使用了

liuhongdi@lhdpc:~/work/gsapi/gsapi$ git config --global user.email "[email protected]"
liuhongdi@lhdpc:~/work/gsapi/gsapi$ git config --global user.name "laoliu"
liuhongdi@lhdpc:~/work/gsapi/gsapi$ git add -A
liuhongdi@lhdpc:~/work/gsapi/gsapi$ git commit -m "info";
[master (根提交) 33122a6] info
 1 file changed, 3 insertions(+)
 create mode 100644 info.php
liuhongdi@lhdpc:~/work/gsapi/gsapi$ 
liuhongdi@lhdpc:~/work/gsapi/gsapi$ git status
位于分支 master
您的分支基于 'origin/master',但此上游分支已经不存在。
  (使用 "git branch --unset-upstream" 来修复)

无文件要提交,干净的工作区
liuhongdi@lhdpc:~/work/gsapi/gsapi$ git push origin master
枚举对象: 3, 完成.
对象计数中: 100% (3/3), 完成.
写入对象中: 100% (3/3), 217 字节 | 217.00 KiB/s, 完成.
总共 3(差异 0),复用 0(差异 0),包复用 0
To ssh://8.1.2.3:22/gsapi
 * [new branch]      master -> master

六,安装过程的报错处理

1,报错

[git@blog ~]$ ./gitolite/install -to /home/git/bin/
Can't locate FindBin.pm in @INC (you may need to install the FindBin module)
(@INC contains: /usr/local/lib64/perl5/5.32 /usr/local/share/perl5/5.32 
/usr/lib64/perl5/vendor_perl/usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5) 
at ./gitolite/install line 9.
BEGIN failed--compilation aborted at ./gitolite/install line 9.

解决:

安装cpan:

[root@blog ~]# yum install perl-CPAN 

配置cpan

[root@blog ~]# perl -MCPAN -e shell
Terminal does not support AddHistory.
To fix that, maybe try>  install Term::ReadLine::Perl
cpan shell -- CPAN exploration and modules installation (v2.29)
Enter 'h' for help.
cpan[1]> install Term::ReadLine::Perl
...

安装FindBin

[root@blog ~]# cpan FindBin
...

 

 

标签:git,centos,hint,blog,gitolite,master,root,stream9
From: https://www.cnblogs.com/architectforest/p/18303368

相关文章

  • git冲突发生原因-两个人同时对文件的同一部分进行了修改
    在甲负责分支 b 的开发,每次修改后推送到远程分支,乙需要将远程分支 b 拉取更新到本地进行测试,并且乙不修改分支 b 的情况下,通常不会产生冲突。这是因为冲突通常发生在不同的人对同一个文件的同一部分进行了不同的修改,而乙只是在拉取和合并更新,并不进行修改。再解释的专业一......
  • git fetch 和 git pull的区别
    gitfetch 和 gitpull 都是用于从远程仓库获取数据的命令,但它们有一些重要的区别:gitfetch:仅从远程仓库获取数据,不会自动合并数据。更新本地存储的远程分支的状态。需要手动合并更新的内容到当前分支。常用于查看远程仓库的变化而不修改当前工作状态。示例:gitfet......
  • git fetch --all 和 git fetch origin 的区别
    gitfetch--all 和 gitfetchorigin 这两个命令在功能上有一些关键的区别:gitfetch--all:获取所有远程仓库的所有分支更新。适用于有多个远程仓库的项目。可以一次性更新所有远程仓库的引用。示例:gitfetch--allgitfetchorigin:获取默认远程仓库(通常命名......
  • 【技巧】git stash用的好,切换分支随便搞
    前言......
  • docker centos7 镜像 systemctl 报错 Failed to get D-Bus connection: Operation not
    从docker下载默认的CentOS镜像没有开启systemd,执行systemctl命令会显示“FailedtogetD-Busconnection:Operationnotpermitted”错误,如果docker创建centos7的容器涉及到systemctl服务操作,或者需要实现容器开机后自动启动服务功能。需要调整镜像并且修改镜像启动方式......
  • GitHub每周最火火火项目(7.8-7.14)
    项目名称:stanford-oval/storm项目介绍:storm是一个由LLM驱动的知识管理系统,它能够对某个主题进行研究,并生成带有引用的完整报告。这个项目的目标是帮助用户更有效地获取和整理信息,通过利用LLM的能力,它可以自动收集、分析和整合相关的知识,为用户提供全面且准确的报......
  • centos8 内核升级教程 执行安装成功后 reboot
    Centos处理步骤先设置DNS为114.114.114.114等CentOS8升级内核到6.9步骤1查看内核现状版本4.18[[email protected]]#hostnamectlStatichostname:localhost.localdomainIconname:computer-vmChassis:vmMachineID:1c063b9ed186473e891a2fe6ac0a072c......
  • 使用idea从本地上传代码到gitee
    1.登陆Gitee(登录-Gitee.com),没有就注册一个2.点击新建仓库3.填完点击创建4.用idea打开一个项目(或创建一个项目),,,file——open(这个不用教了吧)注意:绝大多数项目都包含后端、前端、甚至app、小程序代码,所以本地代码上传到Gitee时一定要选择包含全部项目的文件夹例如:5.这里......
  • 使用内网云+GitHub Pages免费部署动态网站
    目录一、失败的经历1.花生壳2.nat1233.网云穿4.cpolar5.ngrok6.金万维快解析7.神卓互联8.内网云(neiwangyun.net)9.localhost.run10.GitHubPages(pages.github.com)11.IPv612.IPv6+GitHubPages13.FRP14.nps二、终极方案:内网云+GitHubPages一、失败的经历相信......
  • Typora使用Gitee和PicGo搭建免费图床
    Typora使用Gitee和PicGo搭建免费图床一、环境准备1、安装最新版Typora地址:Typora官方中文站2、安装Node.js地址:Node.js1、下载长期服务版LTS下载后,一直默认下一步安装即可2、验证是否安装成功命令行输入以下命令,出现版本号,说明安装成功!node-v二、配置Gi......