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
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.
figure 2
3, the installation is successful, the right mouse button as shown in FIG.
image 3
Click TortoiseGit -> Setttings, Chinese language can be set, click on the "application", as shown in FIG.
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.
Figure 5
Image 6
4, Git Next, again make global settings, the following command Git the Bash completed, as shown in FIG.
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.
Figure 8
完成上述设置后,我们就可以使用HTTP方式操作gitlab的仓库了,先复制项目的HTTP的克隆地址,如图9所示。
图9
使用TortoiseGit来clone仓库,如图10所示,选择“Git 克隆"。
图10
粘贴板会自动将要克隆的地址填入,如图11所示。
图11
点击”确定“,会提示输入用户名和密码,如图12所示。
图12
密码输入正确后,将完成项目克隆到本地的操作,如图13所示。
图13
重要说明:如果在上述操作过程中输错了用户名或密码,点击”确定“时会提示用户名或密码不正确,但不会再弹出输入用户名密码的对话框,此时就得到”控制面板“-->”用户账户"-->"凭据管理"-->"管理Windows凭据",删除对应的凭据即可,如图14所示。
图14
图15
commit+push操作对应SVN的commit。因为Git的commit是先提交到本地仓库,然后再push到gitlab服务器。即git的提交修改操作均保存在本地,不需要连gitlab服务器也可以查看历史修改记录。而SVN不行,如图16所示。
图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
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.
Figure 21
Note that using ssh clone a stop key, URL begins with git @, 22 shown in FIG.
Figure 22
Click "OK", as shown in Figure 23, I x, and being given it, Behind his good embarrassment.
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.
Figure 24
Figure 25
After completion of setting, let us try cloning it, as shown in FIG 26, FIG 27, successfully completed.
26
27
Do not avoid having problems, so that we are gods and goddesses from big step closer ^ _ ^, come on.