Super complete GitLab nanny-level tutorial

One, gitlab installation

1. Download the gitlab package remotely

wget --content-disposition https://packages.gitlab.com/gitlab/gitlab-ce/packages/ubuntu/xenial/gitlab-ce_12.1.4-ce.0_amd64.deb/download.deb

2. Local installation

dpkg -i gitlab-ce_12.1.4-ce.0_amd64.deb

3. Modify the gitlab.rb configuration

vim /etc/gitlab/gitlab.rb

4. Modify GitLab URL

##  GitLab URL 
##! URL on which GitLab will be reachable. 
##! For more details on configuring external_url see: 
##! https://docs.gitlab.com/omnibus/settings/configuration.html#configuring-the-external-url-for-gitlab 
external_url 'http://192.168.1.1:8000'

5. Enter your external_url directly locally

insert image description here

6. After entering the new password, log in

insert image description here

7. finish

2. Add groups and users

1. Click Create a group on the main interface to create a private group, and only members in the group can see the project
insert image description here

2. Click Members under Groups

insert image description here

3. Add user interface

insert image description here

4. Set user permissions

insert image description here

Permission Description:

Guest: Can create issues, post comments, but cannot read and write the repository

Reporter: Code can be cloned but cannot be submitted. QA and PM can grant this permission

Developer: Can clone code, develop, submit, push, normal development can grant this permission

Maintainer: Can create projects, add tags, protect branches, add project members, edit projects, core development can grant this permission

Owner: You can set the value project access permission, Visibility Level, delete project, migrate project, manage group members, and the development team leader can grant this permission

gitlab common commands

Common commands illustrate
sudo gitlab-ctl reconfigure Reload the configuration, execute after each modification of the /etc/gitlab/gitlab.rb file
sudo gitlab-ctl status View GitLab status
sudo gitlab-ctl start Start GitLab
sudo gitlab-ctl stop Stop GitLab
sudo gitlab-ctl restart Restart GitLab
sudo gitlab-ctl tail view all logs
sudo gitlab-ctl tail nginx/gitlab_acces.log View nginx access log
sudo gitlab-ctl tail postgresql View postgresql logs

3. New items

1.New Project

insert image description here

2. Add project properties

insert image description here

3. Create a new project warehouse successfully

insert image description here

4. Git upload project description

Download git, then right-click Git Bash Here on the project folder that needs to be uploaded

insert image description here

Type the git command here, the specific command is in the fifth point

insert image description here

5. Command line guide

You can also upload an existing file from your computer by following the instructions below.

Git global settings

git config --global user.name "XX" 
git config --global user.email "[email protected]"

Create a new repository

git clone http://192.168.1.117:8000/deeplearning/deeplab.git 
cd deeplab 
touch README.md 
git add README.md 
git commit -m "add README" 
git push -u origin master

Push an existing folder

cd existing_folder 
git init 
git remote add origin [http://192.168.1.117:8000/deeplearning/deeplab.git](http://192.168.1.117:8000/deeplearning/deeplab.git) 
git add . 
git commit -m "Initial commit" 
git push -u origin master

Push to an existing Git repository

cd existing_repo 
git remote rename origin old-origin 
git remote add origin http://192.168.1.117:8000/deeplearning/deeplab.git 
git push -u origin --all 
git push -u origin --tags

6. Create and merge branches

1. Create a new branch in New branch on the master branch

insert image description here

2. Merge branches

insert image description here

3. The source branch is the current branch, and the target branch is master by default. Confirm that it is correct and click Submit

insert image description here

Seven, gitlab rollback to a specific version

1. Click commits on gitlab, view and copy the serial number of the version that needs to be rolled back

insert image description here

(This operation is performed in Git Bash)

2. Roll back the local file

$ git reset --hard 5a572cb964f1713d4cc24b8dd86e0e70e7eb9e18

3. Roll back the server code

$ git push -f

Eight, data backup and recovery

1. Change the backup data generation directory

By default, a tar archive will be created in the /var/opt/gitlab/backups directory

Modify the Backup Settings in /etc/gitlab/gitlab.rb

insert image description here

Then reload the configuration file

gitlab-ctl reconfigure

insert image description here

2. Create a backup file

gitlab-rake gitlab:backup:create

Switch to the backups directory to view the generated tar package

insert image description here

3. Data recovery

(1) Change the permission of the backup file to 777 and decompress the file

chmod 777 1659009687_2022_07_28_12.1.4_gitlab_backup.tar

(2) Stop the data connection service

gitlab-ctl stop unicorn 
gitlab-ctl stop sidekiq

(3) Perform data recovery

gitlab-rake gitlab:backup:restore BACKUP=1659009687_2022_07_28_12.1.4

9. Create gitlab in docker

Experimental environment: ubuntu20.04

Search gitlab mirror

docker search gitlab

create container

docker run -d -p 443:443 -p 8000:80 \ 
--name gitlab \ 
--restart always \ 
--privileged=true \ 
-v /srv/gitlab/config:/etc/gitlab \ 
-v /srv/gitlab/logs:/var/log/gitlab \ 
-v /srv/gitlab/data:/var/opt/gitlab \ 
-v /etc/localtime:/etc/localtime:ro \ 
gitlab/gitlab-ce

visit gitlab

http://主机IP:8000

Guess you like

Origin blog.csdn.net/weixin_43367756/article/details/126048316