unbuntu安装git
unbuntu安装git
本文讲解一下 ubuntu 安装和配置 git。
安装git
下面开始安装 git:
sudo apt install git
配置 git 的全局环境:
git config --global user.name "用户名"
git config --global user.email "邮箱"
生成 ssh 秘钥:
ssh-keygen -C '邮箱' -t rsa
1.一直按回车,生成的秘钥文件会在 ~/.ssh。然后将 ~/.ssh 目录下的 id_rsa.pub 里面的内容复制到 git 页面 SSH Key 中 => Settings -> SSH and GPG keys -> New SSH key;
- 随便填标题,粘贴入刚才生成的秘钥:;
- 将 key 加入到 ssh-agent:;
ssh-add ~/.ssh/id_rsa
- 如遇报错:Could not open a connection to your authentication agent,则:;
# 先
ssh-agent bash
# 然后
ssh-add ~/.ssh/id_rsa
- 最后测试连接:;
ssh -T git@github.com
- 不出意外会输出 successfully 巴拉巴拉。