Git SSH Configuration
tenji edited this page Jul 9, 2017
·
3 revisions
Waiting for editing...
- 设置username和email
$ git config --global user.name "tenji"
$ git config --global user.email "shentianzhi@126.com"
- 生成SSH Key
$ ssh-keygen -t rsa -C "shentianzhi@126.com"
连续三个回车之后,可以得到两个文件:id_rsa和id_rsa.pub
- 添加SSH Key到GitHub
登陆GitHub,把id_rsa.pub文件里的内容添加到SSH Keys中,路径:Setting >> SSH and GPS keys >> New SSH key - 测试是否可用
$ ssh -T git@github.com
看到以下提示说明SSH已经可用:
Warning: Permanently added the RSA host key for IP address '192.30.255.113' to the list of known hosts.
Hi tenji! You've successfully authenticated, but GitHub does not provide shell access.
- 修改已有HTTPS工程的URL
修改.git文件夹下config中的url
修改前:
[remote "origin"]
url = https://github.com/tenji/ks.git
fetch = +refs/heads/:refs/remotes/origin/
修改后:
[remote "origin"]
url = git@github.com:tenji/ks.git
fetch = +refs/heads/:refs/remotes/origin/