Github个人代码仓库配置——绑定SSH和账号

Posted on 2023-03-02 16:43  Charlie_ODD  阅读(2)  评论(0编辑  收藏  举报

1.登录github.com

找到个人-settings (https://github.com/settings/keys)
image

2.按照下方的文档命令生成ssh公私钥对

image

--- 查看生成的密钥key
$ls -al ~/.ssh
total 32
drwx------   6 chi  staff   192 12 17 14:54 .
drwxr-x---+ 36 chi  staff  1152 12 17 22:14 ..
-rw-------   1 chi  staff   411 12 17 15:04 id_ed25519
-rw-r--r--   1 chi  staff    99 12 17 15:04 id_ed25519.pub
-rw-------   1 chi  staff  1823 12 17 14:58 id_rsa
-rw-r--r--   1 chi  staff   399 12 17 14:58 id_rsa.pub
---如果存在,则直接将下面命令输出的key复制下来
$cat ~/.ssh/id_rsa.pub
---如果没有生成过,就执行一下命令生成
ssh-keygen -t ed25519 -C "your_email@example.com"  (推荐)
或
 ssh-keygen -t rsa -b 4096 -C "your_email@example.com"  (推荐)
--- 查看
 cat ~/.ssh/id_rsa.pub

3. 将~/.ssh/id_rsa.pub 或 ~/.ssh/id_ed25519.pub复制到github新增ssh公钥的配置框

image

4.git登录账号密码

git init
git config --global user.name "your name "
git config --global user.email "your email"
git remote add origin 远程仓库链接地址
git push -u origin master本地编辑代码后提交至远程分支

image