命令方式

查看远程

1
git remote -v

添加

1
git remote add gitlab https://git.xxx.com/test.git

这个其实就是编辑了.git/config 下面的文件,也可手动编辑

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
[core]
repositoryformatversion = 0
filemode = false
bare = false
logallrefupdates = true
symlinks = false
ignorecase = true
[remote "origin"]
url = git@gitee.com:chenshuzhuo/marvel-message.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
+ [remote "gitlab"]
+ url = https://git.xxx.com/test.git
+ fetch = +refs/heads/*:refs/remotes/gitlab/*
+ tagopt = --no-tags

可视化编辑

TortoiseGit (git小乌龟) 编辑

image-20221021112051815

命令和可视化编辑的效果一样

  • -t 加/解密算法
  • -b 秘钥长度,rsa默认秘钥长度的为 2048
  • -C 注释,一般是填写用户名
  • -f 指定生成的秘钥文件名,如果不提供此参数则使用默认文件名,如rsa私钥默认文件名 ~/.ssh/id_rsa ,公钥默认文件名 ~/.ssh/id_rsa.pub

codding 配置

https://coding.net/help/docs/project-settings/credential.html

1
2
3
ssh-keygen -m PEM -t ed25519  -C "1657428854@qq.com"  -f ~/.ssh/coding
ssh-keygen -t rsa -C "1657428854@qq.com" -f ~/.ssh/github
ssh-keygen -t ed25519 -C "Gitee SSH Key" -f ~/.ssh/gitee
1
2
3
ssh -Tv git@e.coding.net
ssh -T git@github.com
ssh -T git@gitee.com
1
2
3
4
5
6
7
8
9
$ ssh -T git@gitee.com
Hi **! You ve successfully authenticated, but GITEE.COM does not provide shell access.
$ ssh -T git@github.com
Hi **! You ve successfully authenticated, but GitHub does not provide shell access.
$ ssh -T git@codeup.aliyun.com
Welcome to Codeup, **!
$ ssh -T git@e.coding.net
git@e.coding.net: Permission denied (publickey).

在目录下C:\Users\shuzhuoi\.ssh新建配置文件 config

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Host gitee.com
HostName gitee.com
User 1657428854@qq.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/gitee
Host e.coding.net
HostName e.coding.net
User 1657428854@qq.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/coding
Host github.com
HostName github.com
User 1657428854@qq.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/github

image-20231109164438488