The company used vpn before, and the boss told me to make a git. So, I started the research road of git. . . .
Concept: (To be honest, I still don’t quite understand it after reading it)
git is a version control system, a command, a tool
gitlib is a development library for implementing git functions
github is an online code hosting repository based on git, including a website interface, open to the Internet
gitlab is an online code repository hosting software based on git. You can use gitlab to build a similar
The same system as github is generally used to build git private servers in internal networks such as enterprises and schools.
At the beginning, I rented the cheapest linux server directly from Alibaba Cloud, and then just yum -y install git . . . So git is installed. . Then after setting some things on the client, it's ok, and the file code can be uploaded and downloaded. . . Later, how do I want to manage git? Although the client can see the files one by one, the server does not seem to see the files, but there are some more incomprehensible files. . . So I found out that gitlab seems to be able to manage. . . Next, I started my research on gitlab. . .
The first stage: the easiest setup of the git server and the easiest use of the client.
Prepare:
Server: Aliyun server centos 7.4
(It is best to have 4G memory, and no other requirements are required, because in the process of installing gitlab later, I used Alibaba Cloud's cheapest entry-level server at the beginning with a memory of 512M. As a result, various strange things always appeared during the installation process Strange mistake, I read the official document later and said that it is best to prepare 4G memory, but I changed it and installed it at once, which is incredible.)
Client: Company's Mac
Help documentation: http://www.runoob.com/git/git-tutorial.html
https://www.cnblogs.com/ganbo/p/7794281.html
- Step 1: Install git on the server
[root@gitlab ~]# uname -a ——>Device information
Linux gitlab 3.10.0-693.2.2.el7.x86_64 #1 SMP Tue Sep 12 22:26:13 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
[root@gitlab ~]# yum -y install git ——"installation
[root@gitlab ~]# git version ——" View the current version
git version 1.8.3.1
[root@gitlab ~]# useradd git ——"Create git user and password
[root@gitlab ~]# passwd git
Changing password for user git.
New password: 123456 ——————》For the convenience of the experiment, all the places where the password is used are set to 123456
BAD PASSWORD: The password is shorter than 8 characters
Retype new password:
passwd: all authentication tokens updated successfully.
[root@gitlab ~]# su - git ————" Note that unless otherwise specified, the following commands are executed by the git user
[git @ gitlab ~] $ ls
[git@gitlab ~]$
[git@gitlab ~]$ mkdir .ssh
[git@gitlab ~]$ touch .ssh/authorized_keys ————"Create a public key storage location. Also for security, although the ssh-copy-id command can pass the public key directly, the client must know the git password. After creating it directly here, we only need to ask the client to generate the key by itself, and then pass the public key to the git administrator, and the git administrator can add it.
[git@gitlab ~]$ chmod 755 .ssh/
[git@gitlab ~]$ chmod 644 .ssh/authorized_keys
********Remarks: Some people on the Internet say that following the steps below can increase security. . . But I will not do it now, because I use the git user to operate, avoiding a lot of additional permissions that need to be added. The problem. When you are in Baidu, you can see a lot of need to use chown to add git permissions***********
[git@gitlab gitrepo]$ exit ——" first temporarily switch back to root user
logout
[root@gitlab ~]#
[root@gitlab ~]# vim /etc/passwd ———— "Modify as shown in the figure below
At this point, the git user can use git through ssh normally, but cannot log in to the system through ssh. Also for safety.
****************Please don't set the above step if you refer to my article, maybe you can do this after all the projects are set up*** ********************
[git @ gitlab ~] $ ls
[git@gitlab ~]$ pwd
/home/git
[git@gitlab ~]$ mkdir gitrepo ——"Create or select a directory as the storage directory of the git repository
[git@gitlab ~]$ ll
total 4
drwxrwxr-x 2 git git 4096 Apr 27 11:37 gitrepo
[git@gitlab ~]$ cd gitrepo/
[git@gitlab gitrepo]$ git init --bare xiangmu-1.git ————"Create a git empty warehouse xiangmu-1 in the selected directory
Initialized empty Git repository in /home/git/gitrepo/xiangmu-1.git/
[git@gitlab gitrepo]$ git init --bare xiangmu-2.git ————"Create a git empty warehouse xiangmu-2 in the selected directory
Initialized empty Git repository in /home/git/gitrepo/xiangmu-2.git/
[git@gitlab gitrepo]$ git init --bare xiangmu-3.git ————"Create a git empty warehouse xiangmu-3 in the selected directory
Initialized empty Git repository in /home/git/gitrepo/xiangmu-3.git/
[git @ gitlab gitrepo] $ ls
xiangmu-1.git xiangmu-2.git xiangmu-3.git
ok server settings come to an end first. Next, configure it on the client side.
Step 2: mac client settings
Because mac has its own terminal control device. Windows friends can solve it by themselves. Ha ha.
I don't know if it's because I tested it many times before and didn't clean it up, or because the mac comes with the git command. Anyway, I have git commands on my side.
I will introduce two operation methods, one is the download and upload from the command line. One is the upload and download of the git client tool. . . .
Git complete command manual address: http://git-scm.com/docs
PDF version of the command manual: github-git-cheat-sheet.pdf
Let's talk about the operation steps of the terminal control device:
First create the ssh key:
Command: ssh-keygen
Got: id_rsa (private key) id_rsa.pub (public key) these two files
SHIJUNJIE-MAC:~ shijunjie$ pwd
/Users/shijunjie
SHIJUNJIE-MAC:~ shijunjie$ ls .ssh/
id_rsa id_rsa.pub known_hosts
SHIJUNJIE-MAC:~ shijunjie$
Open the public key id_rsa.pub and copy the contents directly to the .ssh/authorized_keys file created on the git server before
SHIJUNJIE-MAC:~ shijunjie$ cat ./.ssh/id_rsa.pub
[git@gitlab ~]$ vim ./.ssh/authorized_keys
Create a directory on the local client to store the git repository, for example:
SHIJUNJIE-MAC:~ shijunjie$ mkdir git
SHIJUNJIE-MAC:~ shijunjie$ cd git/
SHIJUNJIE-MAC: git shijunjie$ pwd
/Users/shijunjie/git
Clone the server-side repository to the local git directory:
SHIJUNJIE-MAC: git shijunjie$ pwd
/Users/shijunjie/git
SHIJUNJIE-MAC: git shijunjie$ git clone [email protected]:/home/git/gitrepo/xiangmu-1.git
Cloning into 'xiangmu-1'...
warning: You appear to have cloned an empty repository.
SHIJUNJIE-MAC: git shijunjie$ ls
xiangmu-1
ok, this is done, the little friends can operate happily.
Git complete command manual address: http://git-scm.com/docs
PDF version of the command manual: github-git-cheat-sheet.pdf
Next, let's talk about client tools.
The tool download address is here:
https://git-scm.com/download/gui/mac。
There are many tools, and the friends could have tried them one by one. . Here I will generously introduce two tools. . .
SourceTree
It feels a bit cumbersome to register, but it's okay to use.
Remember to set it in the settings interface before use, otherwise it will definitely make you crazy. . . .
Account is not required. . .
GitHub Desktop
ok The clone repository of the tools in 2 is probably like this. . . More specific operations need to be explored by the friends themselves, or you can leave a message to me. . .
The second stage: the establishment of the gitlab hosting (management) system
Reference document: https://www.cnblogs.com/ganbo/p/7794281.html
Here I installed it directly using the mirror station of Tsinghua University. Once again, I remind my friends that the memory must be enough. I have not tried 2G, because the 512M entry-level Alibaba Cloud server I used at the beginning failed, and then I used 4G directly. .
https://mirror.tuna.tsinghua.edu.cn/help/gitlab-ce/ . Mirror site
Build steps:
[git@gitlab ~]$ exit ————"Switch back to the root user first
logout
[root@gitlab git]#
[root@gitlab git]# vim /etc/yum.repos.d/gitlab-ce.repo
[gitlab-ce]
name=Gitlab CE Repository
baseurl=https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el$releasever/
gpgcheck=0
enabled=1
[root@gitlab git]# yum makecache
[root@gitlab git]# yum install gitlab-ce
ps: Note that the port set here cannot be occupied. The default is port 8080. If 8080 has been used, please customize other ports and open the corresponding ports in the firewall settings
[root@gitlab git]# gitlab-ctl reconfigure
[root@gitlab git]# gitlab-ctl restart
ok So far, gitlab has been built. . . Let's log in and see.
Just enter the address you set in /etc/gitlab/gitlab.rb to get in. The first login will ask you to enter the username and password, as well as the new password setting.
Initial account: root Password: 5iveL!fe
Since they are all in English, I wonder if there is any Chinese version? In the QQ group: linux learning exchange 148412746, a group friend gave me a link. So I embarked on the sinicization of no return. . .
https://gitlab.com/xhang/gitlab/tree/9-0-stable-zh
I followed this instruction step by step:
[root@gitlab git]# cat /opt/gitlab/embedded/service/gitlab-rails/VERSION
10.7.1
I found the following, and confirmed that the Chinese version contains the version 10.7.1 I am using:
[root@gitlab ~]# pwd ————"Confirm the current position
/root
[root@gitlab ~]# git clone https://gitlab.com/xhang/gitlab.git ——" Clone the Chinese version library
Cloning into 'gitlab'...
remote: Counting objects: 735568, done.
remote: Compressing objects: 100% (152381/152381), done.
remote: Total 735568 (delta 574996), reused 734906 (delta 574378)
Receiving objects: 100% (735568/735568), 294.48 MiB | 2.53 MiB/s, done.
Resolving deltas: 100% (574996/574996), done.
[root@gitlab ~]# ls
gitlab
[root@gitlab ~]# cd gitlab/
[root@gitlab gitlab]# git diff v10.7.1 v10.7.1-zh > ../10.7.1-zh.diff ——" Export Chinese package
[root@gitlab gitlab]# cd
[root@gitlab ~]# ls
10.7.1-zh.diff gitlab
[root@gitlab ~]# gitlab-ctl stop
[root@gitlab ~]# patch -d /opt/gitlab/embedded/service/gitlab-rails -p1 < 10.7.1-zh.diff
[root@gitlab ~]# gitlab-ctl reconfigure ——" recompile
[root@gitlab ~]# gitlab-ctl restart ——"Start
ok. This is installed, let's take a look at the effect:
Ha ha. At this point, the localization is all done, and the next step is to study how to operate this thing. . . .