• Git --05 Gitlab使用


    Gitlab使用

    01. 外观配置

    img

    02. Gitlab汉化配置

    1、下载汉化补丁
    git clone https://gitlab.com/xhang/gitlab.git
    2、查看全部分支版本
    git branch -a
    3、对比版本、生成补丁包
    git diff remotes/origin/10-2-stable remotes/origin/10-2-stable-zh > ../10.2.2-zh.diff
    4、停止服务器
    gitlab-ctl stop
    5、打补丁
    patch -d /opt/gitlab/embedded/service/gitlab-rails -p1 < /tmp/10.2.2-zh.diff
    6、启动和重新配置
    gitlab-ctl start
    gitlab-ctl reconfigure
    

    03. 注册限制

    04. 创建用户及组

    05. 创建用户

    06. 把用户添加到组

    07. 创建项目

    返回首页,进入项目

    #删除github的仓库
    [root@git ~/git_data]# git remote remove origin
    [root@git ~/git_data]# git remote
    #添加gitlab的远程仓库,进行代码上传
    [root@git ~/git_data]# git remote add origin git@10.0.0.100:OPS/git_test.git
    [root@git ~/git_data]# git push -u origin master
    The authenticity of host '10.0.0.100 (10.0.0.100)' can't be established.ECDSA key fingerprint is 
    SHA256:6gbyCCIw3zFuNSUR2Y7UOG8fbSrj/BVUaeXwllvrGXM.
    ECDSA key fingerprint is 
    MD5:95:10:02:7c:71:73:c6:4a:b2:f9:d8:88:5d:4a:3d:e0.
    Are you sure you want to continue connecting (yes/no)? yes
    Warning: Permanently added '10.0.0.100' (ECDSA) to the list of known hosts.
    Counting objects: 17, done.
    Compressing objects: 100% (8/8), done.
    Writing objects: 100% (17/17), 1.25 KiB | 0 bytes/s, done.
    Total 17 (delta 1), reused 0 (delta 0)
    To git@10.0.0.100:OPS/git_test.git
    * [new branch] master -> master
    Branch master set up to track remote branch master from origin.
    

    08. 推送代码到Gitlab

    [root@git ~/git_data]# echo oldboy >>a.txt
    [root@git ~/git_data]# git add .
    [root@git ~/git_data]# git commit -m "create a.txt"
    [master a5c15de] create a.txt
    1 file changed, 1 insertion(+)
    create mode 100644 a.txt
    [root@git ~/git_data]# git push -u origin master
    Counting objects: 4, done.
    Compressing objects: 100% (2/2), done.
    Writing objects: 100% (3/3), 289 bytes | 0 bytes/s, done.
    Total 3 (delta 0), reused 0 (delta 0)
    To git@10.0.0.100:OPS/git_test.git
    0924a70..a5c15de master -> master
    Branch master set up to track remote branch master from origin.
    

    刷新Gitlab仓库

    09. 开发推送代码到Gitlab

    #给其创建dev用户,并给其分配到项目组,然后进行登录

    #克隆一台服务器,作为开发人员使用,并进行生成密钥文件,进行密钥认证

    [root@dev ~]# 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:qx5BldjQ4qy+HTSH9zpg8nVQqJDNP/M8gfq/4k+E09c root@dev
    The key's randomart image is:
    +---[RSA 2048]----+
    | +.=.o |
    | o =.= . |
    | +.+ o |
    | .+.*o. . |
    | .=.S*o.. E |
    | o.+=.==. |
    | . +o+..o. |
    | ...++o |
    | .o+.o=+. |
    +----[SHA256]-----+
    [root@dev ~]# cat .ssh/id_rsa.pub
    ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDa4HBEOk10oode36lPcrybpjK++3bsjbaO67CjzY9S8w2WbAFfsVUwM+Hz8uRlehfjiCxuXF/oQgK2TATDdVYw89CrUMMmjuR1nRKKslA/Xhj0XxIjtUY+86UpVYp0t3963mmHrvoe45DTHYHIQqHEP8FM1fi5T6EzYrVhWFmmjqQYbVYQL+4oHwJBsCvQ4XZ6PCgTBlw2D8s1jk2Sx2vTsPLURA/+iL7WqzM5bGQLcAP5R3yG09v5O0+C/RLIHMw/qY54DaxVGTXhs0PnrfQhdzlUcKREsGkF7Ya3khyfss1jY+/QslS3Y6be9s8sfBKuWwx3Llob2nkgKiZOpQ+5 root@dev        
    

    复制其公钥

    #进行将代码克隆下来,进行更改
    [root@dev ~]# git clone git@10.0.0.100:OPS/git_test.git
    Cloning into 'git_test'...
    The authenticity of host '10.0.0.100 (10.0.0.100)' can't be established.
    ECDSA key fingerprint is 
    SHA256:6gbyCCIw3zFuNSUR2Y7UOG8fbSrj/BVUaeXwllvrGXM.
    ECDSA key fingerprint is 
    MD5:95:10:02:7c:71:73:c6:4a:b2:f9:d8:88:5d:4a:3d:e0.
    Are you sure you want to continue connecting (yes/no)? yes
    Warning: Permanently added '10.0.0.100' (ECDSA) to the list of known hosts.
    remote: Counting objects: 20, done.
    remote: Compressing objects: 100% (10/10), done.
    remote: Total 20 (delta 1), reused 0 (delta 0)
    Receiving objects: 100% (20/20), done.
    Resolving deltas: 100% (1/1), done.
    [root@dev ~]# ll
    drwxr-xr-x 3 root root 52 Nov 17 17:21 git_test
    [root@dev ~]# ll git_test/
    total 8
    -rw-r--r-- 1 root root 16 Nov 17 17:21 a
    -rw-r--r-- 1 root root 7 Nov 17 17:21 a.txt
    -rw-r--r-- 1 root root 0 Nov 17 17:21 test
    
    #修改代码
    [root@dev ~]# cd git_test/
    [root@dev ~/git_test]# echo dev01 >> a
    [root@dev ~/git_test]# git commit -am "dev01 add a"
    
    *** Please tell me who you are.
    Run
    git config --global user.email "you@example.com"
    git config --global user.name "Your Name"
    to set your account's default identity.
    Omit --global to set the identity only in this repository.
    fatal: unable to auto-detect email address (got 'root@dev.(none)')
    #配置邮件及用户信息
    [root@dev ~/git_test]# git config --global user.email
    "dev@example.com"
    [root@dev ~/git_test]# git config --global user.name
    "dev01"
    [root@dev ~/git_test]# git commit -am "dev01 add a"
    [master 6cc6aff] dev01 add a
    1 file changed, 1 insertion(+)
    #推送到远程仓库
    [root@dev ~/git_test]# git push -u origin master
    Counting objects: 5, done.
    Compressing objects: 100% (2/2), done.
    Writing objects: 100% (3/3), 305 bytes | 0 bytes/s, done.
    Total 3 (delta 0), reused 0 (delta 0)
    To git@10.0.0.100:OPS/git_test.git
    a5c15de..6cc6aff master -> master
    Branch master set up to track remote branch master from origin.
    

    10. 分支保护

    #创建一个dev分支

    [root@dev ~/git_test]# git branch dev
    [root@dev ~/git_test]# git push -u origin dev
    Total 0 (delta 0), reused 0 (delta 0)
    remote:
    remote: To create a merge request for dev, visit:
    remote: http://10.0.0.100/OPS/git_test/
    merge_requests/new?merge_request%5Bsource_branch%5D=dev
    remote:
    To git@10.0.0.100:OPS/git_test.git
    * [new branch] dev -> dev
    Branch dev set up to track remote branch dev from origin.
    #登录root用户,进行分支保护
    

    11. 代码合并

    #清除旧的分支,创建新的分支,并切换

    [root@dev ~/git_test]# git branch -d dev
    Deleted branch dev (was 6cc6aff).
    [root@dev ~/git_test]# git checkout -b dev
    Switched to a new branch 'dev'
    [root@dev ~/git_test]# git branch* dev
    master
    #推送到远程仓库
    [root@dev ~/git_test]# git push -u origin dev
    Counting objects: 5, done.Compressing objects: 100% (2/2), done.Writing objects: 100% (3/3), 311 bytes | 0 bytes/s, done.Total 3 (delta 0), reused 0 (delta 0)remote:remote: To create a merge request for dev, visit:remote: http://10.0.0.100/OPS/git_test/merge_requests/new?merge_request%5Bsource_branch%5D=devremote:To git@10.0.0.100:OPS/git_test.git6cc6aff..315f127 dev -> devBranch dev set up to track remote branch dev from origin.#dev分支上面有a文件的最新信息,而master中没有
    

    进行合并分支

    登录root用户进行处理请求

  • 相关阅读:
    ListView添加HeaderView的顺序问题
    shape与selector配合使用实现Tab下划线效果
    在java代码中设置TextView的字体大小,单位设为sp
    一个textView中的文字设置成两种颜色
    Android studio生成类图
    linux常用命令总结
    主机CPU与显卡选择
    电脑与显示器四种接口
    Linux shell
    Linux 常用命令二
  • 原文地址:https://www.cnblogs.com/gongjingyun123--/p/11970462.html
Copyright © 2020-2023  润新知