配置公钥
码云上一个公钥可以多个项目共用,新建第二个项目不需要再次配置公钥。
https://gitee.com/help/articles/4181#article-header0
按如下命令来生成 sshkey:
ssh-keygen -t rsa -C "xxxxx@xxxxx.com"
# Generating public/private rsa key pair...
按照提示完成三次回车,即可生成 ssh key。通过查看 ~/.ssh/id_rsa.pub
文件内容,获取到你的 public key
cat ~/.ssh/id_rsa.pub
# ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC6eNtGpNGwstc....
多个公钥
指本地有多个公钥,比如github的公钥,个人账号的码云公钥,其他账号的码云公钥。
https://blog.csdn.net/roly_yu/article/details/53483258
编辑.ssh文件夹下的config文件
# github
Host github.com
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa_github //github对应的私钥
# coding.net
Host git.coding.net
User youremail.com //coding对应的email
PreferredAuthentications publickey
IdentityFile ~/.ssh/blog //coding对应的私钥
码云上填写公钥
码云上新建项目/仓库
本地拉取项目&本地上传项目(方法一:推荐)
https://blog.csdn.net/Irene1991/article/details/79726420
关键操作 git clone xxxx
获取项目地址
本地拉取项目&本地上传项目(方法二)
https://blog.csdn.net/helloworld183/article/details/72638413
将本地的库链接到远程库
终端中输入: git remote add origin HTTPS链接
本地库连接远程库常见报错
fatal: refusing to merge unrelated histories
致命的:拒绝合并不相关的历史
https://www.centos.bz/2018/03/git-出现-fatal-refusing-to-merge-unrelated-histories-错误/
其实这个问题是因为 两个 根本不相干的 git 库, 一个是本地库, 一个是远端库, 然后本地要去推送到远端, 远端觉得这个本地库跟自己不相干, 所以告知无法合并。推荐使用方法一。
web访问项目
其他:
码云使用手册:
http://git.mydoc.io/?t=180861#text_180861
打开.ssh文件夹
===结束===