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

Essential Gitlab skills for developers

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

Share

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

Earlier, we have built the Gitlab service and talked about some security settings for gitlab, but as a user, how to use gitlab? Please see below.

1. Bind hosts, open C:\ Windows\ System32\ drivers\ etc\ hosts with notepad, bind the IP address of the gitlab server, and map it to a domain name for easy memory and access, as shown in figure 1.

192.168.59.250 gitlab.demo.com

Figure 1

After completing the above hosts settings, we can actually sign up for a gitlab account by visiting http://gitlab.demo.com. It is best to use the company mailbox to register the account. If the mailbox assigned to me by the company is firefly@demo.com, I will use the mailbox to register the gitlab account, and then the configuration administrator will assign the relevant warehouse permissions to the firefly@demo.com account.

After the administrator has assigned the permissions of the relevant group or warehouse, we can log in to http://gitlab.demo.com with our own account to view the content of the project. Is this the end of the operation of gitlab? Of course not. If you want to clone the project locally, modify the project file locally, and then submit it to the gitlab server, we use Git and TortoiseGit for this operation.

2. Install Git and GUI client TortoiseGit and Chinese language pack. The Git download page is on Github: https://github.com/git-for-windows/git/releases

Select TortoiseGit for GUI Clients. The download link is as follows:

Https://download.tortoisegit.org/tgit/2.9.0.0/TortoiseGit-2.9.0.0-64bit.msi

Https://download.tortoisegit.org/tgit/2.9.0.0/TortoiseGit-LanguagePack-2.9.0.0-64bit-zh_CN.msi

After the download is complete, complete the installation in the order of 1, 2 and 3, as shown in figure 2, and the relevant settings can be set by default during the installation process.

Figure 2

3. After successful installation, the right mouse button is shown in figure 3.

Figure 3

Click TortoiseGit-> Setttings, you can set the language to Chinese, and click apply, as shown in figure 4.

Figure 4

Then, in "Icon Overlays", select Shell Extended, as shown in figure 5. The purpose of this setting is that when a file changes in the git repository, the file icon status changes, as shown in figure 6.

Figure 5

Figure 6

4. Then make global settings for Git. The following command is completed with Git Bash, as shown in figure 7.

Figure 7

Set the user name and email address (be careful to use your own mailbox when registering for gitlab)

Git config-global user.name "firefly"

Git config-global user.email firefly@demo.com

Setting color.ui to auto makes the output of the command more readable.

Git config-global color.ui auto

By setting credential.helper to store, you can store users and passwords to avoid manually entering usernames and passwords each time you submit or pull.

Git config-global credential.helper store

The above gitconfig command will generate a .gitconfig file under the user's home directory (Windows is C:\ Users\ xusers,Linux is ~ / .gitconfig), as shown below.

Cat .gitconfig

[user]

Name = firefly

Email = firefly@demo.com

[credential]

Helper = store

[color]

Ui = auto

If you want to change this information again, you can edit the .gitconfig file directly, as shown in figure 8. The name and email address set here will be used in Git's submission log. Since the name and email address of the warehouse will be disclosed along with the submission log when you disclose the warehouse on GitHub, please do not use private information that is inconvenient to be disclosed.

Figure 8

After completing the above settings, we can use HTTP to operate the gitlab repository, first copying the clone address of the project's HTTP, as shown in figure 9.

Figure 9

Use TortoiseGit to clone the repository, as shown in figure 10, select Git Clone.

Figure 10

The pasteboard automatically fills in the address to be cloned, as shown in figure 11.

Figure 11

Click OK and you will be prompted for a user name and password, as shown in figure 12.

Figure 12

When the password is entered correctly, the project will be cloned locally, as shown in figure 13.

Figure 13

Important note: if in the above operation process entered the wrong user name or password, click "OK" will prompt the user name or password is incorrect, but will not pop up the input user name password dialog box, then get the "Control Panel"-> "user account"-> "credential Management"-> "manage Windows credentials", delete the corresponding credentials, as shown in figure 14.

Figure 14

Figure 15

The commit+push operation corresponds to the commit of SVN. Because the commit of Git is first submitted to the local warehouse, and then push to the gitlab server. That is, the submission and modification operations of git are saved locally, and you do not need to even the gitlab server to view the history of changes. Not SVN, as shown in figure 16.

Figure 16

5. After completing the above operations, we have basically met the needs of our daily work. But as a developer, if you don't have SSH access to the git repository, you won't miss the opportunity to say goodbye to being single next time if you are consulted by the new client MM ().

Use the ssh-keygen command to generate the key file, where the id_rsa file is the private key and id_rsa.pub is the public key.

Ssh-keygen-t rsa-C firefly@demo.com uses the above command to enter directly and complete the key generation, as shown in figure 17.

Figure 17 copy the contents of the id_rsa.pub file and add it to the git account firefly@demo.com user, as shown in figure 18.

Figure 18 use the firefly account to log in to the web version of the gitlab service, add the public key in id_rsa.pub in Settings-SSH Keys, and then click "Add key", as shown in figure 19.

Figure 19

Since the gitlab server ssh port does not use the default 22, but 6688, we also need to create the C:\ Users\ tgh\ .ssh\ config file (if you have multiple gitlab servers, you can add them in the config file), as shown in figure 20.

Cat > > .ssh/config

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