Developers skills necessary Gitlab

We have already built a good Gitlab service, also talked about gitlab some security settings, but as a user, how to use gitlab it? See below.

1, bind hosts, use notepad to open the C: \ Windows \ System32 \ drivers \ etc \ hosts, bind gitlab server's IP address mapped to the domain name, easy to remember and access, as shown in Fig.

192.168.59.250 gitlab.demo.com


c7f5f2451dd74ffd861394f324904590

figure 1

After completion of the hosts set up, in fact, we will be able to register the account by visiting gitlab http://gitlab.demo.com. E-mail is best to use a registered account, such as mailbox companies assigned me is [email protected], I will use the mailbox to register gitlab account, and then assign permissions to [email protected] account the relevant warehouse configuration by the administrator.

After administrator assigned the relevant permissions group or warehouse, then we can use their account to log http://gitlab.demo.com view the contents of the project phase. That is not operating on this gitlab finished it? Of course not, if you want to clone the project to local and local modification project file, and finally submitted to gitlab server for this operation, we must rely on Git and TortoiseGit.

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

GUI Clients choose TortoiseGit, the corresponding download links below:

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

Once downloaded, the installation according to the order of 1,2,3, shown in Figure 2, during installation settings are by default.

4090b412b40c43f9a3647a208f63df9c

figure 2

3, the installation is successful, the right mouse button as shown in FIG.

1bbe6965435e49d4bc4d3656a0a7bbeb

image 3

Click TortoiseGit -> Setttings, Chinese language can be set, click on the "application", as shown in FIG.

f5443ff09e9847d3afd0b22b728c03eb

Figure 4

Then, in the "Icon Overlays", select Shell Extended, FIG. 5, the purpose of this setting is that when there git repository files change, the state of the file icon also with the change, the effect is shown in Fig.

a6ae0c99a5114ecfb6a54c67c417360d

Figure 5

f79a0742679d4f01991c3fd08f45b806

Image 6

4, Git Next, again make global settings, the following command Git the Bash completed, as shown in FIG.

a94bd699fb274a84a6c6980526657a93

Figure 7

Set the user name and e-mail address (note that when the mailbox with their registered gitlab)

git config --global user.name "firefly"

git config --global user.email [email protected]

The color.ui set to auto allows output of the command has a higher readability.

git config --global color.ui auto

Store the credential.helper set, the user can store and the password, to prevent manual input user name and password each commit or pull.

git config --global credential.helper store

The above command will git config in the user's home directory (Windows is C: \ Users \ xusers, Linux is ~ / .gitconfig) generated .gitconfig file, as follows.

cat .gitconfig

[user]

name = firefly

email = [email protected]

[credential]

helper = store

[color]

ui = auto

If you want to change this information, can directly edit .gitconfig file, as shown in FIG. Name and e-mail address set here will be used in Git commit log in. Due to open warehouse on GitHub, here's the name and e-mail address will be published together with the commit log, so please do not use private information not be made public.

d5bd9824be8342ef9892c7bb22cede33

Figure 8

完成上述设置后,我们就可以使用HTTP方式操作gitlab的仓库了,先复制项目的HTTP的克隆地址,如图9所示。

6a753aa4459544c9a9d67120f7573e73

图9

使用TortoiseGit来clone仓库,如图10所示,选择“Git 克隆"。

d76a3ff52e3542aba36c09554a2f0074

图10

粘贴板会自动将要克隆的地址填入,如图11所示。

40de8f9ae9c2421eab30498af7e4cee0

图11

点击”确定“,会提示输入用户名和密码,如图12所示。

d9817be3bc41403dbbdb0e3403302592

图12

密码输入正确后,将完成项目克隆到本地的操作,如图13所示。

e1117b66c85f4db9883c5d0f41efac41

图13

重要说明:如果在上述操作过程中输错了用户名或密码,点击”确定“时会提示用户名或密码不正确,但不会再弹出输入用户名密码的对话框,此时就得到”控制面板“-->”用户账户"-->"凭据管理"-->"管理Windows凭据",删除对应的凭据即可,如图14所示。

99fda1a6-44e0-4821-9316-3a92ad9de938

图14

f897873910324445b2c3048b9192120f

图15

commit+push操作对应SVN的commit。因为Git的commit是先提交到本地仓库,然后再push到gitlab服务器。即git的提交修改操作均保存在本地,不需要连gitlab服务器也可以查看历史修改记录。而SVN不行,如图16所示。

6fd191bdd4d44ae38b79bcc6f73f03e5

图16

5、完成上述操作后,就已基本满足我们日常工作需求了。但作为一名开发人员,如果不会SSH访问git仓库的话,下次要是被新入职客户端MM请教会不会就错失了告别单身的机会(哈哈),正所谓技多不压身。

使用ssh-keygen命令生成密钥文件,id_rsa文件是私钥,id_rsa.pub是公钥。

ssh-keygen -t rsa -C [email protected]
使用上面命令,直接回车,完成密钥生成,如图17所示。

图17
复制id_rsa.pub文件中内容并添加到git账户[email protected]用户下,如图18所示。

图18
使用firefly账户登录网页版gitlab服务,在Settings --- SSH Keys中添加id_rsa.pub中的公开密钥,然后点击“Add key”,如图19所示。

图19

Since gitlab server instead of using the default ssh port 22, but 6688, we also need to create the C: \ Users \ tgh \ .ssh \ config file (if more than one gitlab server, can be added in the config file), as 20 FIG.

cat >>.ssh/config <<EOF

host gitlab.demo.com

hostname 192.168.59.250

port 6688

EOF

9307856397ac49ce83a18fa66f7982e1

Figure 20

Well, we can use ssh way to clone the project, as shown in Figure 21, first copy the address to be cloned project.

5948f588a2a046f5a188efbbec1788b7

Figure 21

Note that using ssh clone a stop key, URL begins with git @, 22 shown in FIG.

c58686fa6801443f80c2b1757a2439e5

Figure 22

Click "OK", as shown in Figure 23, I x, and being given it, Behind his good embarrassment.

263a216d8915430da9a9095cdcda3162

Figure 23

Should never be given to a little scared, we just need to set about TortoiseGit network, change my SSH client, modify the path shown in Figure 24 for the former, 25 for the modified path that we use Git from SSH client with to solve this error.

5961691e441a4a699025738bda5fe7d2

Figure 24

b3912205e01b4973bcde1d1910681721

Figure 25

After completion of setting, let us try cloning it, as shown in FIG 26, FIG 27, successfully completed.

0e660e5cbf3c40ac84dfd8562a31060f

26

a05df00e000f462cb0c34d881bfbcb75

27

Do not avoid having problems, so that we are gods and goddesses from big step closer ^ _ ^, come on.

Guess you like

Origin blog.51cto.com/firefly222/2457159