这几天都在研究Git,没办法公司要要抛弃SVN转站Git,废话就不多说,下面我们进行操作演示:
环境:之前搭建的Redis-Master服务器一枚,配置一般般~
工具:TortoiseGit,传说中的小乌龟~
1、安装开发工具与依赖包
[root@redis_master ~]# yum groupinstall "Development tools" \\安装下开发工具,也不是一定要装,只不过自己习惯装起来
===============\\安装依赖包=====================
[root@redis_master ~]# yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel perl-devel
2、安装Git
[root@redis_master ~]# yum install git
3、创建Git用户
[root@redis_master ~]# useradd git
\\切换到git,并且确保所在位置与用户名
[root@redis_master ~]# su - git
[git@redis_master ~]$ pwd
/home/git
[git@redis_master ~]$ whoami
git
\\查看.ssh是否存在,如果不存在请自行创建
[git@redis_master ~]$ ls -a
. .. .bash_history .bash_logout .bash_profile .bashrc gitolite.tar.gz .ssh .viminfo
4、获取Git版本安装
[git@redis_master ~]$ git clone
[git@redis_master ~]$ ls
gitolite.tar.gz \\由于下载速度实在慢,本人使用了线上服务器download并打包传到自己的实验小鸡上面
[git@redis_master ~]$ tar xf gitolite.tar.gz \\解压缩
[git@redis_master ~]$ ls
gitolite gitolite.tar.gz
=========创建用户家目录及安装gitolite
[git@redis_master ~]$ mkdir $HOME/bin
[git@redis_master ~]$ $HOME/gitolite/install -to $HOME/bin
[git@redis_master ~]$ ls . bin/
.:
bin gitolite gitolite.tar.gz
bin/:
commands gitolite gitolite-shell lib syntactic-sugar triggers VERSION VREF
5、配置Gitolite管理员
[git@redis_master ~]$ ssh-keygen -t rsa \\这条为ssh密钥生成命令,我这边已经有了就直接使用了
[git@redis_master ~]$ /home/git/bin/gitolite setup -pk .ssh/id_rsa.pub \\使用管理员公钥安装Gitolite
Initialized empty Git repository in /home/git/repositories/gitolite-admin.git/
Initialized empty Git repository in /home/git/repositories/testing.git/
6、生成管理员仓库gitolite-admin
[git@redis_master ~]$ git clone git@127.0.0.1:gitolite-admin
Initialized empty Git repository in /home/git/gitolite-admin/.git/
The authenticity of host '127.0.0.1 (127.0.0.1)' can't be established.
RSA key fingerprint is 64:df:86:6c:e3:96:c3:52:80:a7:d8:af:27:4a:4c:80.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '127.0.0.1' (RSA) to the list of known hosts.
remote: Counting objects: 6, done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 6 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (6/6), done.
[git@redis_master ~]$ ls
bin gitolite gitolite-admin gitolite.tar.gz projects.list repositories
7、了解gitolite-admin仓库配置及TortoiseGit安装及秘钥生成
[git@redis_master ~]$ cd gitolite-admin/
[git@redis_master gitolite-admin]$ ls conf/ keydir/ .git/
conf/:
gitolite.conf
.git/:
branches config description HEAD hooks index info logs objects packed-refs refs
keydir/:
id_rsa.pub
7.1 .git文件目录为git程序自动生成
7.2 conf名字上就知道是配置文件
7.3 keydir名字上也可以看出是存放key的文件目录
7.4 TortoiseGit安装及秘钥生成
7.2====================修改前============================
[git@redis_master gitolite-admin]$ cat conf/gitolite.conf
repo gitolite-admin \\这里就是定义我们之前第6点讲到的生成管理员仓库