为了账号安全,请及时绑定邮箱和手机立即绑定

git配置ssh

更改名字和邮箱
  • 1.输入你的名字:$ git config --global user.name "myname"

  • 2.输入你的email了:$ git config --global user.email "myemail@email.com" 如图

开始提交
  • 1.在现有目录中初始化仓库,创建一个名为.get文件:$ git init

  • 2.使用命令 git add 开始跟踪一个文件:$ git add README

  • 3.暂存某些需要的修改: $ git commit -m 'frist submit'

  • 4.设置远程仓库地址: $ git remote add origin git@ github.com:robbin/robbin_site.git
    如图:

  • 5.开始提交你的代码:$ git push origin master 如果没有配置ssh会报这个错误:error: failed to push some refs to如图:
配置ssh
  • 1.输入命令:cd ~/.ssh 然后输入: $ ls 会看到以下内容:authorized_keys2 id_dsa known_hosts config id_dsa.pub 如图:

  • 2.如果没有.ssh文件,这个时候你就要输入命令:$ ssh-keygen -t rsa -C "email@email.com" 来创建.ssh,
  • 3.然后你就会看到:Creates a new ssh key using the provided email # Generating public/private rsa key pair.

Enter file in which to save the key (/home/you/.ssh/id_rsa):直接一路enter就可以
Enter same passphrase again: [Type passphrase again]会所提示你输入自己密码输不输都可以

  • 4.完了之后会出现:Your public key has been saved in /home/you/.ssh/id_rsa.pub.
    The key fingerprint is: # 01:0f:f4:3b:ca:85:d6:17:a1:7d:f0:68:9d:f0:a2:db your_email@youremail.com这时候就完成了
添加公钥到你的get
  • 1.查看你生成的公钥:$ cat ~/.ssh/id_rsa.pub
  • 2.你就可以看到自己生成的公钥了如图:

  • 3.登陆你的github帐户。点击你的头像,然后 Settings -> 左栏点击 SSH and GPG keys -> 点击 New SSH key新建公钥title可以随便输key就是你刚刚新建的公钥
  • 4.可以测试下:ssh git@github.com如果输出Hi xxx! You've successfully authenticated, but GitHub does not # provide shell access. Connection to github.com closed.说明成功了如图:

    最后可以把上边提交流程再走一遍,就可以了。
点击查看更多内容
2人点赞

若觉得本文不错,就分享一下吧!

评论

作者其他优质文章

正在加载中
感谢您的支持,我会继续努力的~
扫码打赏,你说多少就多少
赞赏金额会直接到老师账户
支付方式
打开微信扫一扫,即可进行扫码打赏哦
今天注册有机会得

100积分直接送

付费专栏免费学

大额优惠券免费领

立即参与 放弃机会
意见反馈 帮助中心 APP下载
官方微信

举报

0/150
提交
取消