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

Centos 7 deployment and Sinicization of Gitlab and basic Operation

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

Share

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

Gitlab is an open source application developed using Ruby on Rails to implement a Git project repository that can be accessed through the Web interface public or private projects Gitlab has similar functions as Github, able to browse source code, manage defects and comments. You can manage the team's access to the warehouse, and it is very easy for him to browse the submitted version and provide a library of file history. He also provides a code snippet collection feature that makes it easy to reuse code and make it easier to find it later when you need it.

For more information about gitlab, it is recommended to refer to the gitlab official website for detailed understanding!

Blog outline:

First, prepare the environment

Second, install Gitlab

III. Chinese Gitlab

Basic operation of gitlab

5. Basic operation of remote library

6. Reset the gitlab administrator password

First, prepare the environment operating system memory CPUcentos 74G or above dual core II, install Gitlab1) install Gitlab need to rely on [root@gitlab ~] # yum-y install epel-release curl openssh-server openssh-clients postfix cronie policycoreutils-python2) to obtain Gitlab RPM software package

Method 1: obtain the software package through the open source mirror station of Tsinghua University (recommended)

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

Method 2: obtain the software package through the Gitlab official website (used when the network is stable)

[root@gitlab] # wget-- content-disposition https://packages.gitlab.com/gitlab/gitlab-ce/packages/el/7/gitlab-ce-12.3.5-ce.0.el7.x86_64.rpm/download.rpm3) install Gitlabs [root @ gitlab] # rpm-ivh gitlab-ce-12.3.5-ce.0.el7.x86_64.rpm # takes a long time to install, wait patiently Gitlab's logo4 will appear during installation.) modify gitlab's url and execute reconfigure [root@gitlab ~] # vim / etc/gitlab/gitlab.rb # to modify gitlab's configuration file. # omit part of the content external_url 'http://192.168.1.8' # change this to the local IP address to facilitate access to [root@gitlab ~] # gitlab-ctl reconfigure # reconfigure gitlab, even if you do not modify the configuration file, you need to reconfigure gitlab5) web page access test after installation

As shown in the figure:

It can be accessed that there is no problem, but it is all in English. For those who are not good at English, I say it is a headache. Fortunately, we can make it into Chinese in some ways, as follows!

Third, Chinese Gitlab1) to obtain the gitlab Chinese patch pack (if Chinese is not needed) Skip this step) [root@gitlab ~] # head-1 / opt/gitlab/version-manifest.txt # View the version of gitlab gitlab-ce 12.3.5 [root@gitlab ~] # git clone https://gitlab.com/xhang/gitlab.git-b v12.3.5-zh# to get the Chinese patch pack (note that it needs to be consistent with the version of gitlab) [root@gitlab ~] # cd gitlab/ # enter the gitlab directory [root@gitlab gitlab] # git diff v12.3.5 v12.3.5-zh > / root/v12.3.5-zh.diff# to generate a .diff file by comparing the English version with the Chinese version in diff. 2) Import the Chinese patch into gitlab [root@gitlab gitlab] # gitlab-ctl stop # stop gitlab [root@gitlab gitlab] # yum-y install patch [root@gitlab gitlab] # patch- D / opt/gitlab/embedded/service/gitlab-rails-p1

< ../v12.3.5-zh.diff #将刚才的diff文件做为补丁导入到gitlab中#该命令执行过程中,一路回车跳过即可[root@gitlab gitlab]# gitlab-ctl start #启动gitlab[root@gitlab gitlab]# gitlab-ctl reconfigure #重新配置gitlab3)web页面再次访问 如图: 四、gitlab基本操作1)配置SSH方式免密登录[root@gitlab ~]# ssh-keygen -t rsa -C "1454295320@qq.com"#生成秘钥对,一路回车即可,"-C"后是自己的邮箱[root@gitlab ~]# cat ~/.ssh/id_rsa.pub #查看生成的公钥并复制 ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCvNm+nXc59ugb0SGr9iMHDSFjvmdSJk0ORuX3hbjt822Y2ofXysUrIuBSQ1Jn0Rss/LPU54K32i4bIDsa/jD9gIpN/GqU+YP1MQ9bEw3YVUONAs+nYeWJWahQ1rMTeM0HC9aKvNTrNsOqrXIboJymBrs6Odt+1NnZsYHMwA/KlpYCFsi0HQgBzsLbrD5v++cIDTvM/V4rMq6fqFsfWoYYMHWc8JeNMl/aWJV1RhJpt7wm17FEv3XiH+wyoef5ZYI60IkH5qMJkjWhKcRXCWG5SH3nphUb1fmktB4DH92TW/EGw///VQEnE7tkpNjyJpOTXDuHnEk2tw43cctDN2sJH 1454295320@qq.com 回到web页面,操作如下:

2) create a basic library

As shown in the figure:

Go back to the server and enter the test command, as follows:

[root@gitlab ~] # git config-- global user.name "Administrator" [root@gitlab ~] # git config-- global user.email "admin@example.com" [root@gitlab ~] # git clone git@192.168.1.8:root/test01.git # is cloned locally, and enter "yes" as prompted! [root@gitlab ~] # cd test01/ [root@gitlab test01] # touch README.md [root@gitlab test01] # git add README.md [root@gitlab test01] # git commit-m "add README" [root@gitlab test01] # git push-u origin master

Just refresh the web page, as shown in the figure:

5. Basic operation of remote library

When you clone from a remote repository, git actually automatically corresponds the local master branch to the remote master branch, and the default name of the remote repository is origin.

1) View the information of the associated remote library [root@gitlab test01] # git remote # concise information origin [root@gitlab test01] # git remote-v # details origin git@192.168.1.8:root/test01.git (fetch) origin git@192.168.1.8:root/test01.git (push) 2) push the branch to the remote warehouse [root@gitlab test01] # git checkout-b dev # Create and switch to the dev branch [root@gitlab test01] # git push origin dev # push local branches to remote repositories

After refreshing the page, as shown in the figure:

3) solve the problems caused by multi-person cooperation

When our whole team is developing the same branch, if your colleague has modified the content of the branch and pushed it to the remote warehouse before you submit it, and you happen to make changes to the same file and try to push, then the push will fail because the latest data submitted by your colleague conflicts with the data you are trying to submit (your local content is older than the remote warehouse). The solution will be given in the return message that prompts you to push failure. Here we simulate this process.

# enter another directory and clone the remote repository Simulate multiplayer operation [root@gitlab test01] # cd / tmp [root@gitlab tmp] # git clone git@192.168.1.8:root/test01.git [root@gitlab tmp] # cd test01/ [root@gitlab test01] # git checkout-b etc # recreate a branch and switch [root@gitlab test01] # echo-e "touch / tmp/test01" > tmp.txt [root@gitlab test01] # git add tmp.txt [root @ gitlab test01] # git commit-m "commmit from / tmp" [root@gitlab test01] # git push origin etc # push the newly modified content to the remote end

Go back to the web interface and refresh, and you can see the newly submitted branch:

# the above operations are performed in the / tmp directory, and the next operations are performed in the / root directory: [root@gitlab test01] # cd / root/test01/ [root@gitlab test01] # git checkout-b etc [root@gitlab test01] # echo "touch / root/test01.txt" > root.txt [root@gitlab test01] # git add root.txt [root@gitlab test01] # git commit-m "commit from / root" [root@gitlab test01] # git push origin etc # push again The following error To git@192.168.1.8:root/test01.git will occur! [rejected] etc-> etc (fetch first) error: unable to push some references to 'git@192.168.1.8:root/test01.git' hint: update is rejected because the remote version library contains submissions that do not yet exist locally. This is usually due to another hint: a version library has pushed the same reference. You may need to merge remote change prompts (such as' git pull') before pushing again. Tip: see the 'Note about fast-forwards' section' in 'git push-help'' for details. [root@gitlab test01] # git pull origin etc # pull the remote etc branch to the local [root@gitlab test01] # ls # you can see that the files submitted in the / tmp directory exist README.md root.txt tmp.txt [root@gitlab test01] # git push origin etc # and then push the local dev branch to gitlab again to succeed.

Refresh the web page again, and you will have all the content we submitted under the / tmp directory and / root directory under the etc branch, as shown in the figure:

4) merge remote branch [root@gitlab test01] # git checkout master # switch to master branch [root@gitlab test01] # git merge etc # merge etc branch [root@gitlab test01] # ls # View the content under the merged branch README.md root.txt tmp.txt [root@gitlab test01] # git add. [root@gitlab test01] # git commit-m "submit" [ Root@gitlab test01] # git push origin master # push to remote version library

Refresh the web page again, as shown below:

5) delete the remote branch [root@gitlab test01] # git branch-d etc # Delete the local dev branch [root@gitlab test01] # git branch-r-d origin/etc # Delete the specified remote branch [root@gitlab test01] # git push origin: etc # submit the deleted branch to the remote version library [root@gitlab test01] # git branch-d dev [root@gitlab test01] # Git branch-r-d origin/dev [root@gitlab test01] # git push origin: dev # ditto

Refresh the web page again, as follows:

VI. Reset the gitlab administrator password [root@gitlab ~] # gitlab-rails console production # must be the root user logging in to the server to execute the command irb (main): 001irb 0 > user = User.where (id: 1). If first # id is 1, the super administrator irb (main): 002id 0 > user.password = 'yourpassword' # password must be at least 8 characters IRB (main): 003root 0 > user. Save! # Save user modification information If there is no problem, return trueirb (main): 004exit 0 > exit

At this point, log in again, and you need to log in with the new password yourpassword.

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