Overview
GitLab is an open source Git project management application based on Ruby, which provides functions similar to Github. GitLab provides a CE community version, which users can deploy on their own intranet server, which can be used for the project code hosting warehouse within the team.
This article records the process of building an intranet GitLab Server and the problems encountered.
installation
First download the rpm source installation package, most of which are el7 or even el6 on the Internet :
wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-13.0.0-ce.0.el7.x86_64.rpm
Note that this article is based on the CentOS 8 system, edit the above URL to switch to the el8 path, randomly select a version to download, this article did not select the latest version:
wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el8/gitlab-ce-13.0.0-ce.0.el8.x86_64.rpm
installation:
rpm -i
Edit the configuration file:
vim /etc/gitlab/gitlab.rb
View the mode, enter /external_url
enter to find, press n to continue to find downward (N is to find upward), find external_url 'http://gitlab.com'
and modify it to:external_url 'http://192.168.20.111:8090'
Note that every time you modify the configuration file, you need to execute:
gitlab-ctl reconfigure
gitlab-ctl restart
Enter the external_url configured above in the browser address bar. If it cannot be opened, turn off the firewall: the
systemctl stop firewalld
default user name is root, the password is 5iveL!fe, and the system guides you to change the password.
At this point, the installation is successful.
operating
New Group
Root users can add a Group:
Set the visibility level of the Group:
Three levels are introduced:
- Private, private.
- Internal
- Public,
New project project
Before creating a new project, it is best to create a Group first, otherwise the root user will be created by default
:
git clone
the address of: or:http://192.111.11.111:8090/root/test.git
New users
Log out of the root user, and then register a user, such as johnny, set the password johnny233, the mailbox can be filled in, you can successfully log in to the system.
Invite users
Ctrl + Shift + N shortcut key to open Chrome's incognito mode, open a new page, log in as the root user, enter the group just added, and then you can invite users and set user roles and permissions.
Invite users in Group dimension: Invite users
in engineering project dimension:
There are four role permissions:
- Guest,
- Reporter
- Developer
- Maintainer,
Git clone/push
Open the command line to generate SSH key and
add ED25519 SSHkey:
ssh-keygen -t ed25519 -C ""
Add SSH key:
ssh-keygen -t rsa -b 2048 -C "user@email"
Configure the content of the generated pub file into the SSH key to push the code,
Then when git clone the project, use the http protocol, enter the registered user name/password,
Initialize the local project and push it to the remote server
Enter the local project folder, right-click Git Bash Here
, and initialize it git init
as a Git repository. First add .gitignore
files, then add all files git add .
, check the status git status .
, submit git commit -m "init"
,
create a new project on the remote server, and click Git clone to get its address.
Set remote warehouse address:
git remote add origin http://192.111.11.111:8090/root/local-test.git
view status:
git remote -v
obtain remote warehouse and local synchronization merge:
git pull --rebase origin master
enter U/P
git push -u origin master
.gitignore
invalid
Careful developers, when the above git status .
steps are executed, you may see that the configuration file has been added in the root directory of the project .gitignore
, and there are target/
configuration items, but the output:
new file target\classes\add.sql
indicates that it is .gitignore
not effective, but this target
configuration item is obviously no problem of.
Reason:
.gitignore
Only files that have not been tracked can be ignored, so files that have been tracked cannot be ignored.
The solution is to delete the local cache (change to the untracked state), and then submit:
git rm -r --cached .
output:
error: the following file has staged content different from both the
file and the HEAD:
.gitignore
(use -f to force removal)
Execute again:
git rm -r -f --cached .
Then re-add the file git add .
and execute it git status .
. The output is normal, that is, the class file under the target directory will not be added to the temporary storage area.
Note that there is a difference between and in the .gitignore
configuration file .target/
*/target/
problem
johnny user git push
reported an error:
remote: GitLab: You are not allowed to push code to protected branches on this project.
To http://192.111.11.111:8090/root/test.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'http://192.111.11.111:8090/root/test.git'
Because the change permission of the user johnny is developer, there is no push permission for the master branch by default. If you upgrade to the maintainer, you can push to the remote master branch.