• Git学习笔记8


    Gitlab:

    Gitlab是利用Ruby on Rails 一个开源的版本管理系统,实现一个自托管的git项目仓库,可通过web界面进行访问公开或私有的项目。

    Gitlab安装

    安装之前,将虚拟机的内存改成了4个G。内存如果太小,会有502的错误提示信息。

    在清华源中下载gitlab-ce最新的版本:

    Index of /gitlab-ce/yum/el7/ | 清华大学开源软件镜像站 | Tsinghua Open Source Mirror

    gitlab安装和配置:

    wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-16.2.6-ce.0.el7.x86_64.rpm
    
    1. [root@git-server soft]# ll
    2. total 1302648
    3. -rw-r--r-- 1 root root 1333910957 Sep 13 02:04 gitlab-ce-16.2.6-ce.0.el7.x86_64.rpm
    4. [root@git-server soft]#
    5. [root@git-server soft]# rpm -ivh gitlab-ce-16.2.6-ce.0.el7.x86_64.rpm
    6. warning: gitlab-ce-16.2.6-ce.0.el7.x86_64.rpm: Header V4 RSA/SHA1 Signature, key ID f27eab47: NOKEY
    7. error: Failed dependencies:
    8. policycoreutils-python is needed by gitlab-ce-16.2.6-ce.0.el7.x86_64
    9. [root@git-server soft]# yum install -y policycoreutils-python

     

    1. [root@git-server soft]# rpm -ivh gitlab-ce-16.2.6-ce.0.el7.x86_64.rpm
    2. warning: gitlab-ce-16.2.6-ce.0.el7.x86_64.rpm: Header V4 RSA/SHA1 Signature, key ID f27eab47: NOKEY
    3. Preparing... ################################# [100%]
    4. Updating / installing...
    5. 1:gitlab-ce-16.2.6-ce.0.el7 ################################# [100%]
    6. It looks like GitLab has not been configured yet; skipping the upgrade script.
    7. *. *.
    8. *** ***
    9. ***** *****
    10. .****** *******
    11. ******** ********
    12. ,,,,,,,,,***********,,,,,,,,,
    13. ,,,,,,,,,,,*********,,,,,,,,,,,
    14. .,,,,,,,,,,,*******,,,,,,,,,,,,
    15. ,,,,,,,,,*****,,,,,,,,,.
    16. ,,,,,,,****,,,,,,
    17. .,,,***,,,,
    18. ,*,.
    19. _______ __ __ __
    20. / ____(_) /_/ / ____ _/ /_
    21. / / __/ / __/ / / __ `/ __ \
    22. / /_/ / / /_/ /___/ /_/ / /_/ /
    23. \____/_/\__/_____/\__,_/_.___/
    24. Thank you for installing GitLab!
    25. GitLab was unable to detect a valid hostname for your instance.
    26. Please configure a URL for your GitLab instance by setting `external_url`
    27. configuration in /etc/gitlab/gitlab.rb file.
    28. Then, you can start your GitLab instance by running the following command:
    29. sudo gitlab-ctl reconfigure
    30. For a comprehensive list of configuration options please see the Omnibus GitLab readme
    31. https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md
    32. Help us improve the installation experience, let us know how we did with a 1 minute survey:
    33. https://gitlab.fra1.qualtrics.com/jfe/form/SV_6kVqZANThUQ1bZb?installation=omnibus&release=16-2

    看上面的英文信息:

    请为你的Gitlab instance 配置一个URL,通过设置external_url这一项在gitlab.rb 这个文件中。

    然后再执行sudo gitlab-ctl reconfigure命令。

    修改配置文件vim /etc/gitlab/gitlab.rc:

    external_url 'http://192.168.17.118'   # 修改为gitlab服务器的IP地址,对外服务。

    初始化:gitlab-ctl reconfigure

    时间比较久,需要3分钟左右的时间,会自动配置各个组件,并启动。

    然后是查看状态:

    gitlab-ctl status

    从 /etc/gitlab/initial_root_password文件中得到密码,先登录,然后再更改下密码。

    gitlab设置:

    配置邮件服务的用途:

    1)账号注册的时候,有邮件验证;

    2)有合并请求的时候,邮件通知;

    3)修改密码的时候,通过邮件修改;

    Gitlab创建仓库:

    第一步:在gitlab上创建项目(其实也就是存放代码的仓库)。

    第二步:自定义项目名称等信息,现在比较新的版本已经没有描述信息了:

    页面的信息跟github几乎是相同的。

    设置SSH配置:

    直接将之前生成的公钥信息拷贝过来。

    这样开发者跟gitlab也做成了免密的了。

    再看下项目名称:

    1. [root@git-server ~]# git clone git@192.168.17.118:root/myproject.git
    2. Cloning into 'myproject'...
    3. The authenticity of host '192.168.17.118 (192.168.17.118)' can't be established.
    4. ECDSA key fingerprint is SHA256:4dogA08L5gdfaA69BGekE13kzSuIP2vcRp9rsqYnpn0.
    5. ECDSA key fingerprint is MD5:93:34:b9:61:03:cd:00:92:b9:91:3d:b6:6c:7a:84:95.
    6. Are you sure you want to continue connecting (yes/no)? yes
    7. Warning: Permanently added '192.168.17.118' (ECDSA) to the list of known hosts.
    8. remote: Enumerating objects: 3, done.
    9. remote: Counting objects: 100% (3/3), done.
    10. remote: Compressing objects: 100% (2/2), done.
    11. remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
    12. Receiving objects: 100% (3/3), done.
    13. [root@git-server ~]# ll
    14. total 4
    15. -rw-------. 1 root root 1518 Sep 2 02:39 anaconda-ks.cfg
    16. drwxr-xr-x 3 root root 54 Sep 19 12:10 GitTest
    17. drwxr-xr-x 3 root root 35 Sep 20 00:23 myproject
    18. drwxr-xr-x 3 root root 97 Sep 19 21:52 Shell-100-Days
    19. drwxr-xr-x 2 root root 50 Sep 19 23:19 soft
    20. drwxr-xr-x 3 root root 59 Sep 19 20:43 test

    git clone将整个myproject项目克隆下来。

    然后我们再执行代码上传。

    1. [root@git-server myproject]# echo 111 > 1.py
    2. [root@git-server myproject]# git add *
    3. [root@git-server myproject]# git commit -m "Added 1.py"
    4. [main 7686461] Added 1.py
    5. 1 file changed, 1 insertion(+)
    6. create mode 100644 1.py
    7. [root@git-server myproject]# git push -uf origin main
    8. Counting objects: 4, done.
    9. Delta compression using up to 2 threads.
    10. Compressing objects: 100% (2/2), done.
    11. Writing objects: 100% (3/3), 273 bytes | 0 bytes/s, done.
    12. Total 3 (delta 0), reused 0 (delta 0)
    13. To git@192.168.17.118:root/myproject.git
    14. e320f08..7686461 main -> main
    15. Branch main set up to track remote branch main from origin.

    是main分支,不是github上的master分支。 

  • 相关阅读:
    react配置项目路径别名@
    JDK1.8新特性---Optional
    SPC5777CDK3MMO4 IC MCU 32BIT,SPC5777CDK3MME3
    【算法题】8029. 与车相交的点
    T、Class<T>以及Class<?>的理解
    另辟蹊径者 PoseiSwap:背靠潜力叙事,构建 DeFi 理想国
    python01
    阿里云宣布核心产品全面 Serverless 化
    ofxTimeMeasurements——OpenFrameworks插件,可以轻松测量C++代码任何部分的执行时间
    开发知识点-Vue-Electron
  • 原文地址:https://blog.csdn.net/chang_chunhua/article/details/133050662