1. Introduction to gitlab
GitLab is an open source project for a warehouse management system. It uses Git as a code management tool and builds a web service on this basis. GitLab is developed by Ukrainian programmers Dmitriy Zaporozhets and Valery Sizov, and it is written in Ruby language. Later, part of the code was rewritten in Go language and is now widely used by large and medium-sized Internet companies at home and abroad.
The differences between git, gitlab, and GitHub are as follows:
git is a command-based version control system with full command operation and no visual interface.
Gitlab is an online code warehouse software based on git. It provides a web visual management interface and is usually used for collaborative development within an enterprise team.
github is an online code hosting warehouse based on git. It also provides a visual management interface. It also provides free accounts and paid accounts, as well as open and private warehouses. Most open source projects choose github as the code hosting warehouse.
Second, deployment environment
1, close selinux
sed -i "s/SELINUX=enforcing/SELINUX=disabled/ g" /etc/selinux/config
sed -i's/SELINUXTYPE=targeted/#&/' /etc/selinux/config
setenforce 0
2 Set time zonetimedatectl set-timezone Asia/Shanghai
3. Install the tools and software neededyum -y install vim bash-completion wget curl policycoreutils-python
Three, install and deploy gitlab
1, configure firewall to allow http service< /p>
firewall-cmd --permanent --add-service=http
systemctl reload firewalld
2, install postfix
yum -y install postfix
systemctl enable postfix
systemctl start postfix
3, add GitLab package repository and install gitlab
Note: I installed gitlab-ee (enterprise edition) here. If you want to install gitlab-ce (community edition), please replace gitlab-ee with gitlab-ce in the following command.
curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ee/script.rpm.sh | bash
EXTERNAL_URL="http:// 192.168.2.220" yum install -y gitlab-ee
4. Modify the storage warehouse to a non-system diskvim /etc/gitlab/gitlab.rb
git_data_dirs({
"default" => {
"path" => "/data/git-data"
}
})
5. Restart gitlab
gitlab-ctl stop
gitlab-ctl reconfigure
gitlab-ctl start
6. Log in to the web page to configure gitlab
Visit http://192.168.2.220 with the browser. The following page appears, set the root (administrator) user password
Then log in as root user
Four, gitlab use
1, Gitlab account registration
When the browser visits http://192.168.2.220, the following page will appear, click Register
2, create grou p
? Before creating the project, you can create a group
3, create project< /strong>
Create a new project under the group created above
The two addresses in the Clone drop-down box are the remote warehouse addresses of git.
4. Add users to the group
Note: Adding users to the group can only be performed by the root user
5. Set the protected branch of the project
Log in with the user who created the ceshi project before
Select Developers+Maintainers, that is, developers and maintenance The person has the permission to merge and push.
Five. Install the git client
1. Download the git client tool
You need to download the three software in the figure below
< img alt="CentOS 7.6 installation and deployment gitlab" src="/wp-content/uploads/images/os/centos/1626797813962.png" >
2, install Git tool
Double click Git-2.22.0-64-bit.exe, if it says “Do you want to allow this application to make changes to your device?”, please click “Yes”. Then all the way to Next (next step) until the installation is complete.
3. Install the git client
Double-click TortoiseGit-2.8.0.0-64bit.msi, and click Next all the way.
When the page shown below appears, you can perform step 1.1.4 first to install the language pack, and then select Chinese (Simplified) here.
You can also choose English, and then choose the language after the installation is complete.
When the following interface appears, you can click Check now to check Whether the path of git.exe is correct, the git version number shows that the path of git.exe is correct.
The path of git.exe is C:\Program Files\Git\bin. If the path of git.exe is not displayed by default, you can fill it in manually, and then check it with Check now.
Then enter Full name and email
Click “Finish” and the git client tool installation is complete.
4. Install the git language pack
Double-click TortoiseGit-LanguagePack-2.8.0.0-64bit-zh_CN.msi to install the Chinese language pack.
If “Do you want to allow this app to make changes to your device?” appears, click “Yes”.
Click “Next”, the installation is complete.
5. Change the git client language to Chinese
In any directory, right-click in a blank place and select TortoiseGit→Settings
Six, git client use
There are two ways to use Git, http and ssh.
1. http method
URL address: http://192.168.2.220/ceshi/ceshi.git
Create an empty folder locally, then right-click and select “Git Clone…”
When cloning (clone) for the first time, you need to enter the username and password of gitlab
At this time, you can create a new file for testing. The process is pull→add→submit→ Push
2, ssh Method
Right-click the blank space in any directory, select “Git Bash Here”, open the git command line window
Initialize git global configuration
git config --global user. name "Full nam e"
git config --global user.email "your mailbox"
Create an SSH key pair
ssh-keygen -t ed25519 -C "your mailbox"
3: No. directly Press Enter, do not enter anything
Then put the git command line Close the window.
The key is stored in the .ssh directory under your user directory, for example: C:\Users\xuad.ssh
Open the public key file and copy all the contents to your ssh keys on gitlab to save.
Browser visit http://192.168.2.220 to log in to gitlab , The user pull-down menu in the upper right corner select “Settings”, and then click “SSH Keys”
Create an empty folder locally, then right-click and select “Git clone…”
Other operations are similar to http The way is the same.