Git连接到Github
#教程 #命令 #Git
参考: Git安装教程
参考: Git连接Github
第一次配置
设置个人标识
名称
username : 你的名字/昵称
git config --global user.name "username"
邮箱
git config --global user.email "your_email@example.com"
创建密钥
使用ED25519
算法生成密钥
深入了解
ssh-keygen -t ed25519 -C "your_email@example.com"
- 输入文件路径(多配置文件的需求)
- 输入一个密码
- 输入重复密码
多密钥配置
在~/.ssh
目录创建config
文件
- Host: 主机,任意名
- HostName: 主机名,固定
- PreferredAuthentications: 认证方式,可选一种或多种,使用逗号分隔
- publickey:公钥,服务器使用公钥与本地私钥对比
- password: 密码
- IdentityFile: 密钥文件路径
示例:
Host git
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/github/id_ed25519