程序员

Window7下配置SSH连接GitHub

2018-10-12  本文已影响141人  marshal704

配置前提需在本机安装git,请参考Windows7安装Git客户端
1、注册github账号
2、创建仓库

3、配置SSH Key

cd ~/.ssh
ssh-keygen -t rsa -C "github注册邮箱"

4、测试是否配置成功

$ ssh -T git@github.com       # 邮箱地址不需要改。

如果提示Are you sure you want to continue connecting (yes/no)?,输入yes
然后会看到如下文字表示成功连接。
Hi xxx! You've successfully authenticated, but GitHub does not provide shell access. #出现词句话,说明设置成功。

5、配置git
右键打开git bash

6、将本地项目push到GitHub

Administrator@USER-20170516XE MINGW64 ~/Desktop
$ mkdir git

Administrator@USER-20170516XE MINGW64 ~/Desktop/git
$ cd git/

Administrator@USER-20170516XE MINGW64 ~/Desktop/git
$ git init
Initialized empty Git repository in C:/Users/Administrator/Desktop/git/.git/
Administrator@USER-20170516XE MINGW64 ~/Desktop/git (master)
$ echo "hello world" > hello.md
Administrator@USER-20170516XE MINGW64 ~/Desktop/git (master)
$ git add hello.md
Administrator@USER-20170516XE MINGW64 ~/Desktop/git (master)
$ git commit -m "hello.md"   # hello.md是个备注 随便写
Administrator@USER-20170516XE MINGW64 ~/Desktop/git (master)
$ git status
On branch master
nothing to commit, working tree clean

添加github远程仓库
点击Code - Clone or download - Use SSH
最后获得一个为 git@github.com:XXX/test.git的一个URL # test仓库已在第一步创建

Administrator@USER-20170516XE MINGW64 ~/Desktop/git (master)
$ git remote add origin git@github.com:XXX/test.git
Administrator@USER-20170516XE MINGW64 ~/Desktop/git (master)
$ git push -u origin master
Enumerating objects: 1, done.
Counting objects: 100% (3/3), done.
Writing objects: 100% (3/3), 251 bytes | 251.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To github.com:qcmoke/test.git
 * [new branch]      master -> master
Branch 'master' set up to track remote branch 'master' from 'origin'.
上一篇下一篇

猜你喜欢

热点阅读