gitbash客户端使用ssh连接github

来源:互联网 发布:看图王软件下载 编辑:程序博客网 时间:2024/05/29 07:49

一、创建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
粘贴到其中即可

三、测试连接

  1. 配置账户
    git config --global user.email "you@example.com" 配置邮件
    git config --global user.name "Your Name" 配置用户名

  2. 测试连接到github
    ssh git@github.com
    正常情况下,回显如下:
    You’ve successfully authenticated, but GitHub does not provide shell access

四、本地仓库推送到github

  1. 创建github仓库test
    创建完之后出现一些提示
    这里写图片描述

  2. 创建本地仓库

git initecho "# test" >> README.mdgit add README.mdgit commit -m "first commit"
  1. 将本地仓库连接并推送至远程仓库
git remote add origin git@github.com:InspireCode/test.gitgit push -u origin master