美文网首页
设置 github 作为 git 的远程仓库

设置 github 作为 git 的远程仓库

作者: ahcj_11 | 来源:发表于2017-08-15 22:17 被阅读12次

标签(空格分隔): git github


1 测验SSH公钥是否添加到Github账户中

[ahcj@localhost ~]# ssh -T git@github.com
Warning: Permanently added the RSA host key for IP address '192.30.255.113' to the list of known hosts.
Permission denied (publickey).

上面的例子显示登录失败,这是因为我们还未在GitHub账户中添加SSH公钥。这时需要在本地创建SSH公钥,然后将生成的SSH公钥的文件内容添加到Github帐号上去。

2 生成SSH公钥

[ahcj@localhost ~]ssh-keygen -t rsa -C "your_email@youremail.com"

一路按 enter 键,最后会在.ssh目录生产两个文件:id_rsa和id_rsa.pub。
其中/.ssh/id_rsa是私钥文件,/.ssh/id_rsa.pub是公钥文件。

3 添加SSH公钥

# 将公钥输出到剪切板
[ahcj@localhost ~]cat  ~/.ssh/id_rsa.pub | xclip -selection clipboard

# 或者使用 vim 打开 复制所有内容
[ahcj@localhost ~]vim  ~/.ssh/id_rsa.pub

登录你的Github帐号后

  1. 点击右上方的Accounting settings图标
  2. 选择 SSH keys
  3. 点击 Add SSH key
  4. 在Title里填一个你自己喜欢的名称,然后将上面拷贝的~/.ssh/id_rsa.pub文件内容粘帖到Key中
  5. 点击“add key”按钮

4 测试SSH连接Github

[ahcj@localhost ~]$ ssh -T git@github.com
Warning: Permanently added the RSA host key for IP address '192.30.255.113' to the list of known hosts.
Hi xingchuan! You've successfully authenticated, but GitHub does not provide shell access.

5 设置git用户名与邮箱

[ahcj@localhost ~]git config --global user.name "Your Name Here"
[ahcj@localhost ~]git config --global user.email "your_email@example.com"

相关文章

  • 设置 github 作为 git 的远程仓库

    标签(空格分隔): git github 1 测验SSH公钥是否添加到Github账户中 上面的例子显示登录失败,...

  • 学习如何使用git

    学习如何使用git git的初始设置 git仓库的ssh密钥 远程仓库的设置 远程仓库与本地仓库的同步(参考了这篇...

  • git关联远程仓库

    git关联远程仓库 添加远程仓库:git remote add origin git@github.com:exa...

  • git 常用命令

    远程仓库相关命令 检出仓库:git clone git://github.com/xxx/xxx.git 查看远程...

  • git总结

    本地文件夹关联远程仓库 在github上新建远程仓库, 在本地文件夹下 git init 添加远程仓库:git ...

  • 将本地git仓库关联至远程git仓库 2019-11-20(未经

    如何将本地git仓库关联至远程git仓库 以本地git仓库关联GitHub仓库为例: 在github上新建仓库(注...

  • git 的相关命令

    git 1) 远程仓库相关命令 检出仓库:$ git clone git://github.com/jquery/...

  • Git 命 令 大 全

    Git常用操作命令: 1) 远程仓库相关命令 检出仓库:$ git clone git://github[http...

  • Git常用操作

    远程仓库相关命令 检出仓库:$ git clone git://github.com/jquery/jquery....

  • git分支

    ) 远程仓库相关命令 检出仓库:$ git clone git://github.com/jquery/jquer...

网友评论

      本文标题:设置 github 作为 git 的远程仓库

      本文链接:https://www.haomeiwen.com/subject/fhqbrxtx.html