Warehouse Management Gitlab push the local repository gitlab clone warehouse

 

 

The local warehouse pushed to the remote repository gitlab

Push-realization and a local warehouse between gitlab first thing to do ssh authentication

 

Configuration SSHKEY

We have already created GitLab warehouse, and authorized users can use the warehouse, all of our operations are conducted in the WEB page, next we describe how to connect to our warehouse client.

Our warehouse is private, only authorized users can access to the repository, as long as the client's user and our user GitLab binding, clients can access to the warehouse on the GitLab,

We recommend using SSH for client Gitlab tied to the user's specific configuration is as follows:


Ssh client generates the key pair (note windows client can use the encryption rsa):

Our local client generates a public key, the public key assigned to the corresponding user ssh key gitlab

 

[root@ci-node1 ~]# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): 
Created directory '/root/.ssh'.
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
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:dKgV7ndo1haY4XeUseN/yjj7/2AWNH1wC2GpK/fLfuY root@ci-node1
The key's randomart image is:
+---[RSA 2048]----+
|        . .  +*o.|
|       . + +.oo=.|
|        = = + *.o|
|       = . = = o.|
|      . S = = o  |
|         = =   o |
|          o . + o|
|            o* =.|
|            +BOE+|
+----[SHA256]-----+

 

 

[root@ci-node1 ~]# ll .ssh/
total 8
-rw------- 1 root root 1679 Mar 29 17:55 id_rsa
-rw-r--r-- 1 root root  395 Mar 29 17:55 id_rsa.pub

 

[root@ci-node1 ~]# cat .ssh/id_rsa.pub 
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCstYVepXE4/B85nKNU6gaVpPsjGXu6Ql2sKRgRDxsHGmuZVg+q0GD3c0Ml2XkzozswTRuKCcIhZjK/DEGbbgsBEH8q6HHrWCP6vAWb+7wIEvhtJVm6+5zOGA/AorFczEgnm9b2ekPkwAMV7qrOQ1KG9S94U+XRwAtjgNV0MuYx5S0liBr9KBEt8pQ7Fd2TMo95rF3328gGnWLZJWmETjtJaWpLKDgWnQ7BdlK89o6eyYBtdKJfZ5uYM3tgeX8GiRA+daR8fpEruOSpjuvRbyjRStf5ZXPIemL46lXcEDYurnQ4Uucv5F+paqTWnzYHziQOoKd3Jnxgqsh24TZeoEDP root@ci-node1

 

We refer to this as root user and GitLab binding, copy the user's public key, click on the main page user settings GitLab

 

 

Enter the User Settings page, click on the left menu bar SSH KEYS

 

 

SSH KEYS into the management page

 

 

 

The public key can only add here, if you add the private key system error, in addition to a public throughout GitLab added to the system only once, but a GitLab user can add more public.

 

 

 

 Configuring finished, the local client and the authentication is completed gitlab

 

Push the warehouse to the local client GitLab

The git_test warehouse pushed to the remote repository gitlab local warehouse has git_test

First of all we want to git_test warehouse on GitLab configure git_test warehouse on the ci-node1 remote repository,

 Configuring a remote repository for him

 

 

 

[root @ ci-git_test node1] # @ Go Go gitlab remote addr 192.168 . 31.11 : Test / git_test.git 
[root @ ci - node1 git_test] # Go remote 
gitlab

Secondly, using the git push command directly push the local master branch to the remote warehouse warehouse

[root@ci-node1 git_test]# git push -u gitlab master
The authenticity of host '192.168.31.11 (192.168.31.11)' can't be established.
ECDSA key fingerprint is SHA256:Eal3aUwcGcxH1ZD9X799taSiGiCMFgAE7rnoY74f25U.
ECDSA key fingerprint is MD5:27:41:0f:5a:4c:ba:8f:23:bd:23:44:8d:18:53:e6:30.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.31.11' (ECDSA) to the list of known hosts.
Counting objects: 30, done.
Compressing objects: 100% (18/18), done.
Writing objects: 100% (30/30), 2.50 KiB | 0 bytes/s, done.
Total 30 (delta 2), reused 0 (delta 0)
To 192.168.31.11:test/git_test.git
 * [new branch]      master -> master
Branch master set up to track remote branch master from gitlab.

Tip push function, we git_test warehouse on GitLab, you can see us push up the content, 

 

 Certification is correct, now enables integration of local and remote gitlab warehouse, the warehouse can push up

 

Cloning GitLab warehouse to the local client

We want gitlab warehouse cloned into another machine

We install git ci-node2 service on another machine

Reference source installation git this post

https://www.cnblogs.com/mingerlcm/p/11403126.html

 

After installing git git configuration global configuration mailbox name

https://www.cnblogs.com/mingerlcm/p/11403274.html

 

ci-node2 ssh client to generate a public key certification do ssh

[root@ci-node2 ~]# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): 
Created directory '/root/.ssh'.
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
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:pCb3ozG5sS3ZrnkDUsLTD5RTSule2QxE6oCcmAlzKTU root@ci-node2
The key's randomart image is:
+---[RSA 2048]----+
|o.E.  .*+        |
|oB.+ .=o.        |
|+.+..+o..=       |
|    +o=oo o      |
|    .==+S        |
|    .+oo.        |
|     .=+o        |
|      oX+.       |
|      *=o.       |
+----[SHA256]-----+

 

The public key configuration to gitlab

 

 

[root@ci-node2 ~]# ll .ssh/
total 8
-rw------- 1 root root 1675 Mar 29 23:39 id_rsa
-rw-r--r-- 1 root root  395 Mar 29 23:39 id_rsa.pub

 

 

 

First, we configure the ci-node2 client and user GitLab dev binding,

 Ci-node2 the client's public key configured to the user dev binding gitlab

 

User login dev

 

 

 gitlab requires first login dev users need to change the default password

 

 

 Ci-node2 the client's public key configured to the user dev binding gitlab

 

 

 

 

 

 Now certification has been done

Second, cloning warehouse git clone command to the local ci-node2

[root@ci-node2 data]# git clone git@192.168.31.11:test/git_test.git
Cloning into 'git_test'...
The authenticity of host '192.168.31.11 (192.168.31.11)' can't be established.
ECDSA key fingerprint is SHA256:Eal3aUwcGcxH1ZD9X799taSiGiCMFgAE7rnoY74f25U.
ECDSA key fingerprint is MD5:27:41:0f:5a:4c:ba:8f:23:bd:23:44:8d:18:53:e6:30.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.31.11' (ECDSA) to the list of known hosts.
remote: Counting objects: 30, done.
remote: Compressing objects: 100% (18/18), done.
remote: Total 30 (delta 2), reused 0 (delta 0)
Receiving objects: 100% (30/30), done.
Resolving deltas: 100% (2/2), done.
Checking connectivity... done.

我们可以看到已经将 GitLab 上的 git_test 仓库克隆到了 ci-node2 本地,同时为本地仓库添加了一个指向 GitLab 上 git_test 仓库的远程仓库。

执行git clone时候,会默认会仓库添加一个默认的远程仓库 就是gitlab

[root@ci-node2 data]# ll git_test/
total 4
-rw-r--r-- 1 root root 21 Mar 29 23:55 a
-rw-r--r-- 1 root root  0 Mar 29 23:55 master
-rw-r--r-- 1 root root  0 Mar 29 23:55 test

[root@ci-node2 data]# cd git_test/
[root@ci-node2 git_test]# 
[root@ci-node2 git_test]# git remote
origin

 

我们 ci-node2 的 git_test 上创建一个 dev 分支,并将 dev 分支,推送到 GitLab 上

验证是否默认远程仓库 是否是gitlab 

 

建立dev分支

// 建立dev分支
[root@ci-node2 git_test]# git branch dev
// 切换到dev分支
[root@ci-node2 git_test]# git checkout dev
Switched to branch 'dev'

在dev分支,创建一个文件

[root@ci-node2 git_test]# touch dev

提交commit,需要先配置git全局配置

 

[root@ci-node2 git_test]# git add .
[root@ci-node2 git_test]# git commit -m "commit dev on dev branch"
[dev a0e7b8d] commit dev on dev branch
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 dev

 

把dev分支推到gitlab

[root@ci-node2 git_test]# git status
On branch dev
nothing to commit, working tree clean


[root@ci-node2 git_test]# git push -u origin dev
Counting objects: 2, done.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (2/2), 227 bytes | 0 bytes/s, done.
Total 2 (delta 1), reused 0 (delta 0)
remote: 
remote: To create a merge request for dev, visit:
remote:   http://192.168.31.11/test/git_test/merge_requests/new?merge_request%5Bsource_branch%5D=dev
remote: 
To 192.168.31.11:test/git_test.git
 * [new branch]      dev -> dev
Branch dev set up to track remote branch dev from origin.

完成后,我们在 GitLab 上可以看到我们刚推上来的 dev 分支

 

 

 

Guess you like

Origin www.cnblogs.com/mingerlcm/p/12593873.html