• Gerrit 服务器入门使用-项目的创建与克隆


              Gerrit 服务器入门使用-项目的创建与克隆

                                         作者:尹正杰

    版权声明:原创作品,谢绝转载!否则将追究法律责任。

    一.创建克隆项目

    1>.点击"BROWSE"

    2>.点击"CREATE NEW"

    3>.项目创建成功

    二.基于HTTP方式克隆项目

    1>.克隆项目

    [gerrit@node201.yinzhengjie.org.cn ~]$ 
    [gerrit@node201.yinzhengjie.org.cn ~]$ ll
    total 0
    drwxrwxr-x 14 gerrit gerrit 176 Jun 17 09:06 soft
    [gerrit@node201.yinzhengjie.org.cn ~]$ 
    [gerrit@node201.yinzhengjie.org.cn ~]$ 
    [gerrit@node201.yinzhengjie.org.cn ~]$ git clone "http://172.30.1.201:8080/yinzhengjie-code"
    Cloning into 'yinzhengjie-code'...
    remote: Counting objects: 2, done
    remote: Finding sources: 100% (2/2)
    remote: Total 2 (delta 0), reused 0 (delta 0)
    Unpacking objects: 100% (2/2), done.
    [gerrit@node201.yinzhengjie.org.cn ~]$ 
    [gerrit@node201.yinzhengjie.org.cn ~]$ ll
    total 0
    drwxrwxr-x 14 gerrit gerrit 176 Jun 17 09:06 soft
    drwxrwxr-x  3 gerrit gerrit  18 Jun 18 08:30 yinzhengjie-code
    [gerrit@node201.yinzhengjie.org.cn ~]$ 
    [gerrit@node201.yinzhengjie.org.cn ~]$ ll yinzhengjie-code/
    total 0
    [gerrit@node201.yinzhengjie.org.cn ~]$ 
    [gerrit@node201.yinzhengjie.org.cn ~]$ 

    2>.查看Gerrit的用户名

    3>.在git上配置和Gerrit上存在的用户名和邮箱(要进入到已经克隆的项目中)

    [gerrit@node201.yinzhengjie.org.cn ~]$ ll
    total 0
    drwxrwxr-x 14 gerrit gerrit 176 Jun 17 09:06 soft
    drwxrwxr-x  3 gerrit gerrit  18 Jun 18 08:30 yinzhengjie-code
    [gerrit@node201.yinzhengjie.org.cn ~]$ cd yinzhengjie-code/
    [gerrit@node201.yinzhengjie.org.cn ~/yinzhengjie-code]$ 
    [gerrit@node201.yinzhengjie.org.cn ~/yinzhengjie-code]$ git config user.name "jason"
    [gerrit@node201.yinzhengjie.org.cn ~/yinzhengjie-code]$ 
    [gerrit@node201.yinzhengjie.org.cn ~/yinzhengjie-code]$ git config user.email "y1053419035@qq.com"
    [gerrit@node201.yinzhengjie.org.cn ~/yinzhengjie-code]$ 

    4>.下载commit-msg

    [gerrit@node201.yinzhengjie.org.cn ~/yinzhengjie-code]$ curl -Lo .git/hooks/commit-msg http://172.30.1.201:8080/tools/hooks/commit-msg
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100  4781  100  4781    0     0  2119k      0 --:--:-- --:--:-- --:--:-- 2334k
    [gerrit@node201.yinzhengjie.org.cn ~/yinzhengjie-code]$ 

     

    三.通过ssh方式克隆项目

    1>.创建密钥

    [root@node203.yinzhengjie.org.cn ~]# ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsa 
    Generating public/private rsa key pair.
    Your identification has been saved in /root/.ssh/id_rsa.
    Your public key has been saved in /root/.ssh/id_rsa.pub.
    The key fingerprint is:
    SHA256:jjm9d783Ac7qfftXmgCPRmI6fJ/5yf74YHZSi4ofw7I root@node203.yinzhengjie.org.cn
    The key's randomart image is:
    +---[RSA 2048]----+
    |                 |
    |                 |
    |                 |
    |        o o  .   |
    |     . oSo +o o  |
    |      +=..o o= o.|
    |      +o+o+oB.ooo|
    |       . ==Oo*ooo|
    |        Eo+=*=*+*|
    +----[SHA256]-----+
    [root@node203.yinzhengjie.org.cn ~]# 

    2>.点击设置

    3>.点击“SSH Keys”

    4>.点击"SSH keys",将公钥拷贝到Gerrit上后点击"ADD NEW SSH KEY"

    5>.公钥添加成功

    6>.查看ssh的克隆命令

    7>.使用ssh的方式克隆代码

    [root@node203.yinzhengjie.org.cn ~]# ll
    total 0
    [root@node203.yinzhengjie.org.cn ~]# 
    [root@node203.yinzhengjie.org.cn ~]# git clone "ssh://jason@node201.yinzhengjie.org.cn:29418/yinzhengjie-code"
    Cloning into 'yinzhengjie-code'...
    The authenticity of host '[node201.yinzhengjie.org.cn]:29418 ([172.30.1.201]:29418)' can't be established.
    ECDSA key fingerprint is SHA256:Mx8JcnxxxM/b99YiBG6+S8JP8Q12GNFYz0g/0+YO4c0.
    ECDSA key fingerprint is MD5:c0:2a:ae:84:31:99:7b:fb:80:b3:e8:a5:d9:42:75:6a.
    Are you sure you want to continue connecting (yes/no)? yes
    Warning: Permanently added '[node201.yinzhengjie.org.cn]:29418,[172.30.1.201]:29418' (ECDSA) to the list of known hosts.
    remote: Counting objects: 2, done
    remote: Finding sources: 100% (2/2)
    remote: Total 2 (delta 0), reused 0 (delta 0)
    Receiving objects: 100% (2/2), done.
    [root@node203.yinzhengjie.org.cn ~]# 
    [root@node203.yinzhengjie.org.cn ~]# ll
    total 0
    drwxr-xr-x 3 root root 18 Jun 19 00:03 yinzhengjie-code
    [root@node203.yinzhengjie.org.cn ~]# 
    [root@node203.yinzhengjie.org.cn ~]# ll yinzhengjie-code/
    total 0
    [root@node203.yinzhengjie.org.cn ~]# 
    [root@node203.yinzhengjie.org.cn ~]# 

    8>.使用另一种方式进行克隆

    [root@node203.yinzhengjie.org.cn ~]# ssh -p 29418 jason@172.30.1.201
    
      ****    Welcome to Gerrit Code Review    ****
    
      Hi jason, you have successfully connected over SSH.
    
      Unfortunately, interactive shells are disabled.
      To clone a hosted Git repository, use:
    
      git clone ssh://jason@node201.yinzhengjie.org.cn:29418/REPOSITORY_NAME.git        #我们根据提示,这种克隆方式也是ok的
    
    Connection to 172.30.1.201 closed.
    [root@node203.yinzhengjie.org.cn ~]# 
  • 相关阅读:
    Silverlight4 GDR3与Silverlight5 EAP1的变化
    使用微软WPF技术开发产品优势究竟在那里
    于娟——《活着就是王道》博客精华文摘
    Silverlight中开发和设计人员的合作
    ubuntu10.10编译内核步骤
    添加系统调用实验步骤
    SinaWeiboSdk c++test
    【转】windows7下硬盘安装linux,双系统共存
    cppunit在vs2008下使用的环境搭建(上)
    【转】RedHat Linux 5 安装 OpenOffice 3.2.0
  • 原文地址:https://www.cnblogs.com/yinzhengjie/p/11037705.html
Copyright © 2020-2023  润新知