您的位置:首页 > 运维架构 > Shell

gitbash客户端使用ssh连接github

2017-07-27 23:07 537 查看

一、创建SSH key

ssh-keygen -t rsa -C "youremail@example.com"


一路回车即可。公密匙存在~/.ssh/id_rsa.pub中,复制其中的内容到剪贴板

二、Github账户中添加SSH key

你的github账户->settings->SSH and GPG keys->new SSH key

粘贴到其中即可

三、测试连接

配置账户

git config --global user.email "you@example.com"
配置邮件

git config --global user.name "Your Name"
配置用户名

测试连接到github

ssh git@github.com


正常情况下,回显如下:

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

四、本地仓库推送到github

创建github仓库test

创建完之后出现一些提示



创建本地仓库

git init
echo "# test" >> README.md
git add README.md
git commit -m "first commit"


将本地仓库连接并推送至远程仓库

git remote add origin git@github.com:InspireCode/test.git
git push -u origin master
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  github