一、Git本地设置
- git config --global user.name "github用户名(要加"",并且写在""里面)"
- git config --global user.email "github邮箱(要加"",并且写在""里面)"
- git config --global push.default simple
- git config --global core.quotepath false
- git config --global core.editor "code --wait"
- git config --global core.autocrlf input
二、GitHub添加ssh key
- 生成密钥: ssh-keygen -t ed25519 -C "github邮箱(要加"",并且写在""里面)"
- 密钥路径: C:\Users\YourUsername.ssh
- 上传公钥: 文件后缀为.pub的是公钥,将内容全部复制
- 测试连接: ssh -T git@github.com
使用别名登录服务器
- 在.ssh文件夹中创建config文件(没有后缀名)
- 文件格式如下
Host 别名
HostName 服务器ip
User 服务器用户名
- ssh-copy-id 别名
- ssh 别名(无需输入密码)