git|gitee

Git 全局设置:

git config --global user.name "用户名" git config --global user.email "邮箱"

通过HTTPS的方式:创建 git 仓库:
mkdir project cd project git init touch README.md git add README.md git commit -m "first commit" git remote add origin https://gitee.com/project.git git push -u origin master

已有仓库?
cd existing_git_repo git remote add origin https://gitee.com/project.git //第一次推送 git push -u origin master //后面推送 git push

通过SSH的方式: 创建 git 仓库:
mkdir project cd project git init touch README.md git add README.md git commit -m "first commit" git remote add origin git@gitee.com:xxx/project.git git push -u origin master

已有仓库?
cd existing_git_repo git remote add origin git@gitee.com:xxx/project_02.git git push -u origin master

在命令中输入 ssh-keygen -t rsa -C "xxxxx@qq.com"
输入命令行之后,直接点击enter键即可(三次)。
此时可以进入到本地电脑的C盘里面.ssh文件夹里面查看,输入命令行:ls,如下
id_rsa:为本地SSH私钥
id_rsa.pub:为本地SSH公钥
进入本地SSH公钥文件查看并获取该公钥,输入命令行:cat id_rsa.pub
复制该本地公钥
登录码云账号,在设置里面找到SSH公钥,并点击进去
把刚刚复制到的本地SSH公钥
点击确定提交之后,就可以了
验证:
在终端中输入 ssh -T git@gitee.com : 出现下列提示,说明配置成功!
Hi username! You've successfully authenticated, but GITEE.COM does not provide shell access.

已经配置好SSH密钥,依然报错权限不允许。
$ ssh -T git@gitee.com
The authenticity of host 'gitee.com (212.64.62.183)' can't be established.
ED25519 key fingerprint is xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'gitee.com' (ED25519) to the list of known hosts.
git@gitee.com: Permission denied (publickey).
解决方案:
重新配置ssh密钥,更换加密算法
ssh-keygen默认使用rsa进行加密,但是上面报错提示使用的使用ED25519算法进行解密的,所有只需要换成ED25519算法生成密钥就行。 ssh-keygen -t ed25519 -C "xxx@qq.com"
cat ~/.ssh/id_ed25519.pub
【git|gitee】git|gitee
文章图片

    推荐阅读