Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Installation and basic use of Gitlab (1)

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

(1) introduction

Git is a little bit.

1. Git is distributed, but svn is not

Git distributed local can be used, you can save a variety of history traces, do not have to worry about polluting the server, not even the server can submit code, view log.

2. The GIT branch is different from the SVN branch.

A branch is actually a copy in a version repository in SVN, while a repository in git is a snapshot, so git switching, merging branches, and so on are faster.

3. Git has a powerful code warehouse management system-gitlab.

You can easily manage permissions, code review, create and manage project

GitLab is an open source project for warehouse management system, which uses Git as a code management tool and builds web services on this basis. Public or private projects can be accessed through the Web interface. It has features similar to Github, the ability to browse source code, manage defects and comments. You can manage the team's access to the warehouse, which is very easy to browse the submitted version and provides a file history library. Team members can communicate using the built-in simple chat program (Wall). It also provides a code snippet collection feature that makes code reuse easy.

Version: GitLab is divided into Community Edition (CE) and Enterprise Edition (EE)

(2) installation

Method 1: install through yum source

1. Configure the yum source

[root@otrs004097 ~] # cat / etc/yum.repos.d/gitlab-ce.repo [gitlab-ce] name=Gitlab CE Repositorybaseurl= https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el$releasever/gpgcheck=0enabled=1

2. Update the local yum cache

Sudo yum makecache

3. Install GitLab Community Edition

Sudo yum install gitlab-ce # automatically installs the latest version

Sudo yum install gitlab-ce-x.x.x # installs the specified version

4. GitLab common commands

Sudo gitlab-ctl start # starts all gitlab components; sudo gitlab-ctl stop # stops all gitlab components; sudo gitlab-ctl restart # restarts all gitlab components; sudo gitlab-ctl status # checks service status; sudo gitlab-ctl reconfigure # starts services; sudo vim / etc/gitlab/gitlab.rb # modifies default configuration files; gitlab-rake gitlab:check SANITIZE=true-- trace # checks gitlab;sudo gitlab-ctl tail # View logs

Method 2: install through rpm package

Gitlab integrates the software it needs by downloading the rpm package, simplifying the installation steps. The rpm package can obtain https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/. from the official website or Tsinghua Mirror Source. Download the latest version: https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-12.4.2-ce.0.el7.x86_64.rpm

[root@otrs004097 opt] # wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-12.4.2-ce.0.el7.x86_64.rpm

[root@otrs004097 opt] # rpm-ivh gitlab-ce-12.4.2-ce.0.el7.x86_64.rpm

Or

[root@otrs004097 opt] # yum localinstall-y gitlab-ce-12.4.2-ce.0.el7.x86_64.rpm

(3). Modify the configuration file.

[root@otrs004097 ~] # vim / etc/gitlab/gitlab.rb

External_url 'http://192.168.4.97'

[root@otrs004097 ~] # gitlab-ctl reconfigure # reload configuration

Be careful to keep the 8080 port or you will report an error. You can modify the following configuration file vim / var/opt/gitlab/gitlab-rails/etc/unicorn.rb

Listen "127.0.0.1 true 8080",: tcp_nopush = >

After the reset is successful, you can log on to the web page.

Note: the daemon of gitlab will enable nginx by default. If you want to turn it off, you can try it.

Gitlab-ctl stop nginx

Gitlab-ctl restart nginx

If you want to release resources, you can try to do so when you close gitlab

Gitlab-ctl stop

(4) the use of gitlab

1. Log in to gitlab and enter relevant information in the browser

2. The default account is root, and the password has just been reset.

3. Install Git tool linux: install Git and install it with its own source.

[root@otrs004097 opt] # yum install git-y

4. Generate the key file and use ssh-keygen to generate the key file. Ssh/id_rsa.pub.

[root@otrs004097 opt] # ssh-keygenGenerating public/private rsa key pair.Enter file in which to save the key (/ root/.ssh/id_rsa): 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:at+BXYp8LPxfZ6U00BssEFb1LhvnyphuhFpOyRYYBMo root@otrs004097The key's randomart image is:+--- [RSA 2048]-+ | .o. + o. | |. . .. . O. | | E o o +. | |. . O + | | S. +. * + | | + = Bo.. O. | | o * *. + + | |. .. =. = + | |. SHA256 = o | +-[SHA256]-+

5. Create a new project in the gitlab home page.

6. The client generates a key file

[root@DEV004021 ~] # cat / root/.ssh/id_rsa.pub

Ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDjYPFEWZ/TqT750fQnsoYgzVtjp9NyT3dVPF8BnUJ8coDQLixoYFevXeWbOhECoYI5ekY/6PgLjy3yVJ8uX3BitluHybttO3QhtvmNVRhHTilSyX2c6fxDMIouD08Xnda1w3I9mD8SD+Xg/OCy/8V+QWpfvC1D+oU6Hkt9UyEKgxZ5hnInnc4dWJgpuGsHKa2Hqrr3VImPaSeJ1xVuYl8jsxQjSa1+zIzDbfM0NLCfT/1FGPLCJ4kjOKTFIv3AHn3y9hwTs1H1RrE5bv5H4fNpjG1GsOGKw9MxSP2mV9RHhOI4ItiMK0NNNrZVVa+Lgs50/8s9cn3tWzaHiXNWPEWR root@DEV004021

Copy the public key to gitlab

View the completion of ssh key addition

7. Click the project to view the ssh address and http address

(5) downloading and uploading files on the client side

1. Go to the appropriate directory and download the code

[root@DEV004019 data] # mkdir / opt/gitlab [root@DEV004019 data] # cd / opt/gitlab/ [root@DEV004019 gitlab] # git clone http://192.168.4.97/root/jeeson.gitCloning into 'jeeson'...Username for' http://192.168.4.97': rootPassword for 'http://root@192.168.4.97': remote: Enumerating objects: 6, done.remote: Counting objects: 100% (6max 6), done.remote: Compressing objects: 100% (3max 3) Done.remote: Total 6 (delta 0), reused 0 (delta 0) Unpacking objects: 100% (6 root@DEV004019 gitlab), done. [root@DEV004019 gitlab] # lltotal 0drwxr-xr-x 4 root root 64 Nov 20 16:48 jeeson

2. Edit the corresponding script file

[root@DEV004019 jeeson] # vim testlqb.shecho "this is test shell"

3. Add the new files to the index

[root@DEV004019 jeeson] # git add testlqb.sh

4. Submit the file to the local warehouse

[root@DEV004019 jeeson] # git commit-m "this is test shell" [master 380ea1d] this is test shell 1 file changed, 1 insertion (+) create mode 100644 testlqb.sh

5. Synchronize files to the gitlab server

[root@DEV004019 jeeson] # git push-u origin masterUsername for 'http://192.168.4.97': rootPassword for' http://root@192.168.4.97': Counting objects: 4, done.Delta compression using up to 4 threads.Compressing objects: 100% (2), done.Writing objects: 100% (3 bytes), 286 bytes | 0 bytes/s, done.Total 3 (delta 1) Reused 0 (delta 0) To http://192.168.4.97/root/jeeson.git c47a84c..380ea1d master-> masterBranch master set up to track remote branch master from origin.

6. View the web page of the gitlab server

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report