ubuntu git环境搭建以及经过SSH链接Github(免密码)配置

Git本地环境配置

1. 安装git

sudo apt-get install git

2. 配置用户信息

$ git config --global user.name "Your Name"
$ git config --global user.email Your_email@example.com

3. 初始化本地仓库配置

git init

经过SSH链接Github

1. 安装SSH

sudo apt-get install ssh

首先 ssh-keygen 会确认密钥的存储位置和文件名(默认是 .ssh/id_rsa),而后他会要求你输入两次密钥口令,留空便可。因此通常选用默认,所有回车便可。git

2. 建立密钥文件

ssh-keygen -t rsa -C "你的github帐号邮箱"

默认密钥文件路径在~/.sshid_rsa是私钥文件,id_rsa.pub是公钥文件github

3. 将公钥添加到Github

  1. id_rsa.pub文件内容所有复制
  2. 登录到GitHub上,右上角小头像->Setting->SSH and GPG keys中,点击new SSH key。

4. SSH测试

ssh -T git@github.com

若是结果为 “ ...You've successfully authenticated, but GitHub does not provide shell access”,则说明成功。shell

5. 设置远程仓库

git remote add origin git@github.com:Username/Repositories_Name.git

若是手误输错,可经过git remote remove origin命令删除该远程仓库。ssh

6.最终测试

  1. 在本地建立更改
  2. git add xxx
  3. git commit -m "xxxxxx"
  4. git push origin master

OK!ide

相关文章
相关标签/搜索