[root@gitlab ~]# cat .ssh/id_rsa.pub ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCmv4aEEEpbUyzv1r6SN0JqOfeyQ7sZZbXxWFv4xflIJeK/rl8cF7UYCzjLEvwJlrkIjKSs5uW1x0zWEcZFiv5tGCiO7DeMR6pKUAn7NzNjKiCcElCXiqHVew84iTbxX4MWKlbFoJYO9/wQ1NlrQfqcSgZwJTLKBMVoMXvTWPPGXf6AwdSp68guFwwGDIV8BiHZiy61bKiWYSVKSDP47Y7VUV/bdwGaxG7tAfalWVpe6xXXRtsj58sENyIWbRI7/9XWqs+eV+CgI74YjOanMvHnHFlfg0tb+MewRb4tFGVmroFBRsvfI3Sl2fez2zHG0qh3f34/0KF1kitlWkgcBJqN root@gitlab
Windwos上获得密钥的方法(需要安装git for windows)
default@Hzs-Desktop MINGW64 /i/Desktop $ ssh-keygen.exe Generating public/private rsa key pair. Enter file in which to save the key (/c/Users/default.DESKTOP-U9D5JP4/.ssh/id_rs a): Created directory '/c/Users/default.DESKTOP-U9D5JP4/.ssh'. Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /c/Users/default.DESKTOP-U9D5JP4/.ssh/id_r sa. Your public key has been saved in /c/Users/default.DESKTOP-U9D5JP4/.ssh/id_rsa.p ub. The key fingerprint is: SHA256:aqnHq/xNn159jBX4o2L2ZJdtiwu4ietvKRT2fL9igZo default@Hzs-Desktop The key's randomart image is: +---[RSA 2048]----+ | | | . | | . . | | o . .| | . S . o.| | + +.o ..++| | .= +.o=++oo=| | . ooE.+==*.oo.| | +++=*== .=o. | +----[SHA256]-----+ default@Hzs-Desktop MINGW64 /i/Desktop $ default@Hzs-Desktop MINGW64 /i/Desktop $ cat /c/Users/default.DESKTOP-U9D5JP4/.ssh/id_rsa.pub ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC15+1oQBzvgzQP3p0Lb9FsTKFfIIws9WxGBVl2B9d2 qT2eKFgXoEDNCF/OrhhXvbMDhORxXHf9RG0Aqj+/vJddbaQpCawHhP6VUG1X885xhY4OohDOkFQiWD1s DCMkX7OHNW5ake6P8AdNwI6eSpKYKYCxRMGkRiBa1KDRtG8CvsG8VN0iTSW0UZ3s4Ps+S31pBYlNjOMv Lp0HRAMVhYimLLi0Wz2mBffPOeNjPX1FfJdr+hO7TIRNdyAEGIhSbckkAnVEIASAhI0Re/19v1RnSkk2 VtBvc5rVeGxFMNuEIl9WDMSTcedhEGXyRlW2N9TtXlvF1eNflzUg2BtCaCFZ default@Hzs-Desktop
密钥创建完成后进行添加
密钥添加成功
1.10.3 创建仓库准备工作已经完毕,右上角点击创建一个新的仓库
创建仓库,输入个人信息
根据上面的提示,创建一个代码仓库
在个人主机上进行推送测试
[root@gitlab ~]# mkdir -p clsn [root@gitlab ~]# cd clsn/ [root@gitlab clsn]# echo "# test" >> README.md [root@gitlab clsn]# git init 初始化空的 Git 版本库于 /root/clsn/.git/ [root@gitlab clsn]# git add README.md [root@gitlab clsn]# git commit -m "first commit" [master(根提交) 089ae47] first commit 1 file changed, 1 insertion(+) create mode 100644 README.md [root@gitlab clsn]# git remote add origin git@github.com:clsn-git/test.git [root@gitlab clsn]# git push -u origin master The authenticity of host 'github.com (192.30.255.113)' can't be established. RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8. RSA key fingerprint is MD5:16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added 'github.com,192.30.255.113' (RSA) to the list of known hosts. Counting objects: 3, done. Writing objects: 100% (3/3), 212 bytes | 0 bytes/s, done. Total 3 (delta 0), reused 0 (delta 0) To git@github.com:clsn-git/test.git * [new branch] master -> master 分支 master 设置为跟踪来自 origin 的远程分支 master。
推送完成,刷新界面就可以发现,推送上去的README.md文件
创建新文件,进行拉取测试
创建好后点击下面的commit即可
github添加成功,进行拉取测试
1.10.4 拉取文件测试查看目录内容
[root@gitlab clsn]# ls README.md
进行拉取