#GitLab的使用方法和配置信息
###公司gitlab的地址:http://10.10.0.20:5080
###github的地址:http://git.github.com
###git码云的地址:http://git.oschina.net
##方法一:手动配置
###一、ssh key配置
####1、windows系统下创建.ssh文件夹
win: C:\Users\Administrator.ssh
md ~/.ssh
####2、mac系统下创建.ssh文件夹
win: C:\Users\Administrator.ssh
cd ~/.ssh
#####注:计算机的keygen位置为C:\Program Files\Git\usr\bin中找到ssh-keygen
####3、进入cmd命令行执行命令
#####私钥之注释的设置
$ ssh-keygen -t rsa -C “066534@600869.com”
注:2022.3最新改版规则,使用RSA加密的不安全,换成ed25519,即:
$ ssh-keygen -t ed25519 -C “066534@600869.com”
其他规则不变,请注意,否则会报error:
You‘re using an RSA key with SHA-1, which is no longer allowed. Please use a newer client
######执行完后提示如下:
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/Administrator/.ssh/id_rsa): id_gitlab
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in id_gitlab.
Your public key has been saved in id_gitlab.pub.
The key fingerprint is:
SHA256:BKMh4/k/534JFaHgjtRGkgSTguJ7DU96M49Bi5cYxzI 066534@600869.com
The key's randomart image is:
+---[RSA 2048]----+
|. =++.= .. |
|+..=.B + .. |
|o.o + + o . |
| . E O . . |
| . ^ + S. |
| . = % .|
| . o O .. . |
| . = o |
| .o. |
+----[SHA256]-----+
步骤:
######1)写入注释命令
######2)写入id_gitlab(可自定义名称,生成的key的名字)
######3)输入密码,一般设置gitlab登录时的密码
######4)执行完上面步骤成功后会生成私钥id_gitlab,公钥id_gitlab.pub
#####在C:\Users\Administrator.ssh下,用记事本打开id_gitlab.pub文件,内容全部复制到gitlab的SSH Keys中(公钥的配置)
###以上配置的是gitlab的配置方法,如果一台计算机同时还需要配置github、码云的话,我们的操作是:
##1、在C:\Users\Administrator.ssh中创建config的文件,无后缀,里面需要给他配置不同的host和私钥名称,即:
Host *10.10.0.20*
IdentityFile ~/.ssh/id_gitlab
Host *github.com*
IdentityFile ~/.ssh/id_github
Host *oschina.net*
IdentityFile ~/.ssh/id_gitos
其他操作雷同上面的方法一(从第三步开始执行)
##方法二:命令行配置信息
###进入公司的gitlab的地址后create new project,创建完成后在Project的里面有Command line instructions提示你根据命令行来执行下面的命令,从而配置相关信息。如下:
####Command line instructions
#####Git global setup
git config --global user.name “yangwang”
git config --global user.email “066534@600869.com”
//git config --list // 查看配置
#####Create a new repository
git clone git@10.10.0.20:yangwang/MMB.git
cd MMB
touch README.md
git add README.md
git commit -m “add README”
git push -u origin master
#####Existing folder or Git repository
cd existing_folder
git init
git remote add origin git@10.10.0.20:yangwang/MMB.git
git add .
git commit
git push -u origin master
###测试配置连接
ssh -T git@github.com
ssh -T git@10.10.0.20
#####提示:Welcome to GitLab, yangwang!