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

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

                                     作者:尹正杰

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

 

 

一.创建克隆项目

1>.点击"BROWSE"

Gerrit 服务器入门使用-项目的创建与克隆_第1张图片

2>.点击"CREATE NEW"

Gerrit 服务器入门使用-项目的创建与克隆_第2张图片

3>.项目创建成功

Gerrit 服务器入门使用-项目的创建与克隆_第3张图片

 

二.基于HTTP方式克隆项目

1>.克隆项目

[[email protected] ~]$ 
[[email protected] ~]$ ll
total 0
drwxrwxr-x 14 gerrit gerrit 176 Jun 17 09:06 soft
[[email protected] ~]$ 
[[email protected] ~]$ 
[[email protected] ~]$ 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.
[[email protected] ~]$ 
[[email protected] ~]$ 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
[[email protected] ~]$ 
[[email protected] ~]$ ll yinzhengjie-code/
total 0
[[email protected] ~]$ 
[[email protected] ~]$ 

2>.查看Gerrit的用户名

Gerrit 服务器入门使用-项目的创建与克隆_第4张图片

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

[[email protected] ~]$ 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
[[email protected] ~]$ cd yinzhengjie-code/
[[email protected] ~/yinzhengjie-code]$ 
[[email protected] ~/yinzhengjie-code]$ git config user.name "jason"
[[email protected] ~/yinzhengjie-code]$ 
[[email protected] ~/yinzhengjie-code]$ git config user.email "[email protected]"
[[email protected] ~/yinzhengjie-code]$ 

4>.下载commit-msg

[[email protected] ~/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
[[email protected] ~/yinzhengjie-code]$ 

 

三.通过ssh方式克隆项目

1>.创建密钥

[[email protected] ~]# 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 [email protected]
The key's randomart image is:
+---[RSA 2048]----+
|                 |
|                 |
|                 |
|        o o  .   |
|     . oSo +o o  |
|      +=..o o= o.|
|      +o+o+oB.ooo|
|       . ==Oo*ooo|
|        Eo+=*=*+*|
+----[SHA256]-----+
[[email protected] ~]# 

2>.点击设置

Gerrit 服务器入门使用-项目的创建与克隆_第5张图片

3>.点击“SSH Keys”

Gerrit 服务器入门使用-项目的创建与克隆_第6张图片

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

Gerrit 服务器入门使用-项目的创建与克隆_第7张图片

5>.公钥添加成功

Gerrit 服务器入门使用-项目的创建与克隆_第8张图片

6>.查看ssh的克隆命令

Gerrit 服务器入门使用-项目的创建与克隆_第9张图片

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

[[email protected] ~]# ll
total 0
[[email protected] ~]# 
[[email protected] ~]# git clone "ssh://[email protected]: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.
[[email protected] ~]# 
[[email protected] ~]# ll
total 0
drwxr-xr-x 3 root root 18 Jun 19 00:03 yinzhengjie-code
[[email protected] ~]# 
[[email protected] ~]# ll yinzhengjie-code/
total 0
[[email protected] ~]# 
[[email protected] ~]# 

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

 

[[email protected] ~]# 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://[email protected]:29418/REPOSITORY_NAME.git        #我们根据提示,这种克隆方式也是ok的

Connection to 172.30.1.201 closed.
[[email protected] ~]# 

 

转载于:https://www.cnblogs.com/yinzhengjie/p/11037705.html

你可能感兴趣的:(Gerrit 服务器入门使用-项目的创建与克隆)