码迷,mamicode.com
首页 > 其他好文 > 详细

github 笔记

时间:2015-01-05 18:26:27      阅读:170      评论:0      收藏:0      [点我收藏+]

标签:

如果你已经安装了GitHub的windows客户端,就可以忽略此文。

1. 下载git 命令行工具 http://git-scm.com/

2.生成sshkey

2.1 cd 到保存key的文件夹

技术分享

2.2 生成sshkey

技术分享

出现第一个提示,

Enter file in which to save the key ,请输入将要生成的文件名

Enter passphrase (empty for no passphrase): 这个文件的密码
# Enter same passphrase again:这个文件的密码

2.3 添加到ssh-agent
技术分享
这里要输入刚才的密码

如果出现 Could not open a connection to your authentication agent. 错误

在shell下执行  $ ssh-agent bash --login -i  然后执行  $ ssh-add 就好了哈。

(http://www.tangrucheng.com/implementation-of-ssh-add-could-not-open-a-connection-to-your-authentication-agent-errors.html)、

 

 技术分享

2.4 把刚生成的文件,内容拷贝出来

 

 技术分享

类似这种的

技术分享

拷贝到 sshkeys里面

https://help.github.com/articles/generating-ssh-keys/

Now that you have the key copied, it‘s time to add it to GitHub:

  1. 技术分享In the top right corner of any page, click .

  2. 技术分享In the user settings sidebar, click SSH keys.

  3. 技术分享Click Add SSH key.

  4. In the Title field, add a descriptive label for the new key. For example, if you‘re using a personal Mac, you might call this key "Personal MacBook Air".
  5. 技术分享Paste your key into the "Key" field.
  6. 技术分享Click Add key.
  7. Confirm the action by entering your GitHub password.

Test everything out

To make sure everything is working, you‘ll now try SSHing to GitHub. When you do this, you will be asked to authenticate this action using your password, which was the passphrase you created earlier.

Open up your Git Bash and type:

ssh -T git@github.com
# Attempts to ssh to GitHub

You may see this warning:

# The authenticity of host ‘github.com (207.97.227.239)‘ can‘t be established.
# RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.
# Are you sure you want to continue connecting (yes/no)?

Don‘t worry! This is supposed to happen. Verify that the fingerprint in your terminal matches the one we‘ve provided up above, and then type "yes."

# Hi username! You‘ve successfully authenticated, but GitHub does not
# provide shell access.

在Git 命令行里面使用的时候,如果启用了二次验证,需要用person token代替密码使用。
否则会报错

git push “Authentication Failed”

问题解答在这里

http://stackoverflow.com/questions/17659206/git-push-authentication-failed

If you enabled two-factor authentication in your Github account you won‘t be able to push via HTTPS using your accounts password. Instead you need to generate a personal access token. This can be done in the application settings of your Github account. Using this token as your password should allow you to push to your remote repository via HTTPS. Use your username as usual.

Source: https://help.github.com/articles/https-cloning-errors#provide-access-token-if-2fa-enabled

Creating a token

  1. 技术分享In the top right corner of any page, click .

  2. 技术分享In the user settings sidebar, click Applications.

  3. 技术分享Click Generate new token.

  4. 技术分享Give your token a descriptive name.
  5. 技术分享Select the scopes you wish to grant to this token. The default scopes allow you to interact with public and private repositories, user data, and gists.
  6. 技术分享Click Generate token.
  7. 技术分享Copy the token to your clipboard. For security reasons, after you navigate off this page, no one will be able to see the token again.

Remember to keep your tokens secret; treat them just like passwords! They act on your behalf when interacting with the API. Don‘t hardcode them into your programs. Instead, opt to use them as environment variables.

When you‘re done using your token, feel free to click Delete to get rid of it permanently.

 

 



 

github 笔记

标签:

原文地址:http://www.cnblogs.com/xiaokang088/p/4204203.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!