问题内容

git -c color.branch=false -c color.diff=false -c color.status=false -c diff.mnemonicprefix=false -c core.quotepath=false -c credential.helper=sourcetree push -v --tags --set-upstream origin refs/heads/stdev:refs/heads/stdev 
Pushing to https://gitee.com/***.git
remote: [31m[session-734c4f90] Access denied[0m
fatal: unable to access 'https://gitee.com/***.git/': The requested URL returned error: 403
Completed with errors, see above

问题原因

没有推送权限

问题解决

1、配置账户的公钥,参考网站

https://gitee.com/profile/sshkeys
ssh-keygen -t ed25519 -C "Gitee SSH Key"

-t key 类型 -C 注释
输出,如:

Generating public/private ed25519 key pair.
Enter file in which to save the key (/home/git/.ssh/id_ed25519):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/git/.ssh/id_ed25519
Your public key has been saved in /home/git/.ssh/id_ed25519.pub
The key fingerprint is:
SHA256:ohDd0OK5WG2dx4gST/j35HjvlJlGHvihyY+Msl6IC8I Gitee SSH Key
The key's randomart image is:
+--[ED25519 256]--+
|    .o           |
|   .+oo          |
|  ...O.o +       |
|   .= * = +.     |
|  .o +..S*. +    |
|. ...o o..+* *   |
|.E. o . ..+.O    |
| . . ... o =.    |
|    ..oo. o.o    |
+----[SHA256]-----+

中间通过三次回车键确定

2、读取公钥文件 ~/.ssh/id_ed25519.pub:

cat ~/.ssh/id_ed25519.pub

输出,如:

ssh-ed25519 AAAA***5B Gitee SSH Key

复制终端输出的公钥。

添加部署公钥
复制生成后的 ssh key,通过仓库主页 「管理」->「部署公钥管理」->「添加部署公钥」 ,将生成的公钥添加到仓库中。

添加部署公钥

通过 ssh -T 测试时,输出 Anonymous:

$ ssh -T git@gitee.com

Hi Anonymous! You’ve successfully authenticated, but GITEE.COM does not provide shell access.

添加成功后,就可以使用 SSH 协议对仓库进行拉取。

Logo

瓜分20万奖金 获得内推名额 丰厚实物奖励 易参与易上手

更多推荐