分布式版本控制系统Git在CentOS7.4部署方法

Git 介绍(来源于度娘)

Git是一款免费、开源的分布式版本控制系统,用于敏捷高效地处理任何或小或大的项目。

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


切入正题,下面开始部署git-server

[root@git-server ~]# yum -y install git                                    //安装主程序
[root@git-server ~]# groupadd git                                       //创建git用户组
[root@git-server ~]# useradd git -g git -s /bin/git-shell                   //创建git用户,指定基本组及登录shell
[root@git-server ~]# mkdir /git                                         //创建目录用于git数据仓库
[root@git-server git]# git init --bare test.git                             //创建git仓库
Initialized empty Git repository in /git/test.git/
[root@git-server git]# chown -R git.git /git                                //修改仓库所在目录属主属组

以下两步骤在git-client执行

[root@git-client ~]# ssh-keygen -t rsa -f /root/.ssh/id_rsa -N ''             //在客户端创建密钥用于免验证登录
[root@git-client ~]# scp .ssh/id_rsa.pub 10.8.8.63:/root                    //拷贝公钥至server端

再次返回git-server

[root@git-server ~]# mkdir /home/git/.ssh/                              
[root@git-server ~]# cat id_rsa.pub >>/home/git/.ssh/authorized_keys    //将client公钥写入git用户认证文件,多个公钥可逐行写入

接下来就可以去git-client clone 了

[root@git-client ~]# yum -y install git                              //安装主程序
[root@git-client git-clone]# git config --global user.name liu           //配置个人信息, Git 为每个提交都记录名字与电子邮箱地址,所以第一步需要配置用户名和邮箱地址
[root@git-client git-clone]# git config --global user.email liu@abc.com
[root@git-client ~]# mkdir /git-clone                                   //创建目录用于本地仓库
[root@git-client ~]# cd /git-clone/
[root@git-client git-clone]# git clone git@10.8.8.63:/git/test.git      //克隆远程仓库至本地,同SVN的checkout
Cloning into 'test'...
warning: You appear to have cloned an empty repository. 
[root@git-client git-clone]# ls                                           //克隆成功后当前目录下会产生对应项目目录
test
[root@git-client git-clone]# cd test
[root@git-client test]# touch hello.php                                  //创建hello.php文件用于测试
[root@git-client test]# git add hello.php                                // git add 命令可将该文件添加到缓存
[root@git-client test]# git commit -m "test"                            //git commit 将缓存区内容添加到仓库中
[master (root-commit) 065448d] test
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 hello.php
[root@git-client test]# git push                                       //git push 命令将本地仓库所有更新提交至远程仓库
      至此,Git就算是部署完成了,至少可以用了对吧!!!大笑
      

      如果团队很小,把每个人的公钥收集起来放到服务器的/home/git/.ssh/authorized_keys文件里就是可行的。如果团队有几百号人,就没法这么玩了,这时,就可以用Gitosis来管理公钥了。


如果需要使用到Gitosis,可关注另一篇关于此工具的用法,链接如下:
http://blog.csdn.net/qq_36806379/article/details/79188862



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值