1. 初次安装git配置用户名和邮箱
$ git config --global user.name "xxx" $ git config --global user.email "xx@163.com"
2. git使用ssh密钥
$ ssh-keygen -t rsa -C "xxx@126.com"
3.生成密钥对
cat ~/.ssh/id_rsa.pub
ssh-rsa B3NzaC1yc2EAAAADAQABAAABAQDDLFAvtyxdR0TGyLHsSDFk/PjBbG2QIqNiyuStWrOy1bjL/c615lLjWS26zVf++zI6d7Vdcfrc/L7YRMng099O3CunXVYmlaRJj5Uii0IW6/dFZPmCa2QtAOvuJRJLGKtGLa6vxvqMwvUzsvHz64QCzXIotcFlewKKTlRvrxArOuwEskgcX7/Vr71XZoaz72Bs4LSTZ6NQPrfkbb6ku0hws9ERy2wtnoSpo2wkXkODvdzpDtuxAIYQhxnLEMHyWkvCG9RVW6UDkHWpf9+KbJWzKz9g0I1CC58iDP3BBkr/O+hBT7/inFSD
4. 添加公钥到你的远程仓库(github)
远程添加完后验证
$ ssh -T git@github.com
Hi xxx! You've successfully authenticated, but GitHub does not # provide shell access. 成功 5、修改git的remote url
$ git remote -v
origin https://github.com/someaccount/someproject.git (fetch)
origin https://github.com/someaccount/someproject.git (push)