生成ssh公钥和私钥对

ssh-keygen -t rsa -C '邮箱地址'

复制公钥

打开~/.ssh/id_rsa.pub文件(~表示用户目录,比如我的windows就是C:\Users\Administrator),复制其中的内容

gitlab上添加公钥

Profile Settings-->SSH Keys--->Add SSH Key