github推送本地项目

2018-05-04  本文已影响12人  琥珀虎

github配置ssh key

1、使用Git Bash生成新的ssh key。

  `$ cd ~  #保证当前路径在”~”下`
  `$ ssh-keygen -t rsa -C "xxxxxx@yy.com"  #github注册时自己的邮箱`
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/xxxx_000/.ssh/id_rsa):   #不填直接回车
Enter passphrase (empty for no passphrase):   #输入密码(可以为空)
Enter same passphrase again:   #再次确认密码(可以为空)
Your identification has been saved in /c/Users/xxxx_000/.ssh/id_rsa.   #生成的密钥
Your public key has been saved in /c/Users/xxxx_000/.ssh/id_rsa.pub.  #生成的公钥
The key fingerprint is:
e3:51:33:xx:xx:xx:xx:xxx:61:28:83:e2:81 xxxxxx@yy.com

终端出现上述内容表示,本机已完成ssh key设置,其存放路径为:c:/Users/xxxx_000/.ssh/下。

2、添加ssh key到github

3、测试ssh keys是否设置成功。

$ ssh -T git@github.com

The authenticity of host 'github.com (192.30.252.129)' can't be established.
RSA key fingerprint is 16:27:xx:xx:xx:xx:xx:4d:eb:df:a6:48.
Are you sure you want to continue connecting (yes/no)? yes #确认你是否继续联系,输入yes
Warning: Permanently added 'github.com,192.30.252.129' (RSA) to the list of known hosts.
Enter passphrase for key '/c/Users/xxxx_000/.ssh/id_rsa':  #生成ssh kye是密码为空则无此项,若设置有密码则有此项且,输入生成ssh key时设置的密码即可。

出现此句话,说明设置成功。

Hi xxx! You've successfully authenticated, but GitHub does not provide shell access.

git本地登录:

git config --global user.name "yourname"
git config --global user.email "youremail"

将本地项目push到Github

cd Desktop/mask(这是我的项目文件)
git init
git remote add origin git@github.com:yourname/yourrepo.git
git add -A(意为将此文件目录下的所有文件添加上)
git commit -m "task"
git push -u origin master

结语

希望我的文章能够帮助到你,感谢阅读。

上一篇下一篇

猜你喜欢

热点阅读