Connect local git repo to GitHub with ssh

1、确保本地装有git客户端

http://www.git-scm.com

2、本地生成ssh密钥对

ssh-keygen

将公钥上传至GitHub的Setting——SSH keys中,并git的shell中尝试登录:

ssh -T git@github.com

如果返回如下内容,说明连接成功。

You’ve successfully authenticated, but GitHub does not provide shell access.

3、克隆远程仓库

git clone 仓库地址

4、pull最新仓库内容

git remote add origin 仓库地址
git pull origin master

5、修改本地项目,增删代码

6、增加评论

git add .
git commit -m "增加一条评论"

7、推送到(push)仓库

git push -u origin master

如果不使用SSH登录,也可以使用https方式,在git命令中加入

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

Disclaimer
  1. License under CC BY-NC 4.0
  2. Copyright issue feedback: dig +short txt issue.imzye.com
  3. Not all the commands and scripts are tested in production environment, use at your own risk
  4. No privacy information is collected here
Buy Me a Coffee