当前位置 : 首页 » 文章分类 :  开发  »  GitHub

GitHub

GitHub使用笔记


Failed to connect to github.com port 443: Operation timed out

1、打开 https://github.com.ipaddress.com/ 得到 github.com 的ip
2、打开 https://fastly.net.ipaddress.com/github.global.ssl.fastly.net#ipinfo 得到 github.global.ssl.fastly.net 的ip
3、打开 https://github.com.ipaddress.com/assets-cdn.github.com 得到 assets-cdn.github.com 的ip,是4个

编辑 /etc/hosts 增加

140.82.114.3 github.com
199.232.69.194 github.global.ssl.fastly.net
185.199.108.153 assets-cdn.github.com
185.199.109.153 assets-cdn.github.com
185.199.110.153 assets-cdn.github.com
185.199.111.153 assets-cdn.github.com

双因子认证

GitHub 双因子认证可以通过短信验证码 或 token app 来设置。短信验证码不支持大陆手机号,国内使用的话只能通过 token app
使用 authy app 进行双因子认证。authy app 需要在 google play 下载安装。
设置双因子认证之前,GitHub 会让记录有些恢复码,当双因子认证收不到验证码时,可使用恢复码来验证,需要保存下来。

personal access token

开启双因子认证后,在命令行使用 https 类型的 git 仓库地址时 GitHub 登录密码就不能用了,需要输入 personal access token 来代替密码。
注意命令行不会显示提示使用 personal access token 代替密码。

创建 personal access token
Developer settings -> Personal access tokens -> Generate new token,选择 scopes 勾选 repo -> Generate token
生成 personal access token 后要保存下来,关闭页面后就找不到了。

Creating a personal access token
https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token


GitHub Android 客户端推荐

GitHub 的官方Android客户端在几年前就不维护了,但有好多开源的 Android 客户端可供选择,可以看下面的topic
github-client 标签,所有的GitHub客户端
https://github.com/topics/github-client
github-android 标签,Android 客户端
https://github.com/topics/github-android

其中接star比较多的有

安装了 OpenHub 和 FastHub 试用,整体上更偏爱 OpenHub 一些。
都可以用账号/密码 或 access token 登录
用了一段时间后删了 FastHub,只保留 OpenHub


GitHub 应用授权管理

GitHub 授权登录的所有App、客户端、小程序、网站,都可以在 GitHub 上管理,不想授权时随时可撤回。但是好像不能单个权限管理。
Settings - Applications
https://github.com/settings/applications


GitHub应用授权管理

GitHub 微信小程序

huangjianke/Gitter 可能是目前颜值最高的GitHub微信小程序客户端
https://github.com/huangjianke/Gitter

kezhenxu94/mini-github 可能是功能最全的 GitHub 微信小程序
https://github.com/kezhenxu94/mini-github


GitHub for Windows 桌面版密钥问题

目前的GitHub Windows桌面版已经不需要手动生成和上传ssh keys,系统会自动生成,也在目录~/.ssh下,私钥和公钥分别为github_rsa和github_rsa.pub,并且会自动将公钥上传到GitHub网站。
注意:安装GitHub桌面版后,会自动修改SSH的配置文件~/.ssh/config中的”IdentityFile”为github_rsa,从而导致使用Git Bash命令行push代码时出现Permission denied (publickey)错误**,但通过GitHub桌面提交代码没有问题。
建议:还是不要装GitHub桌面版了,这个问题困扰我好几天,还是用命令行好,自己ssh-keygen生成密钥,手动添加到GitHub。

由于SSH配置文件的不匹配,导致的Permission denied (publickey)及其解决方法
http://blog.itpub.net/25851087/viewspace-1262468/

Error when push commits with Github: fatal: could not read Username
http://stackoverflow.com/questions/20871549/error-when-push-commits-with-github-fatal-could-not-read-username

Git push requires username and password
http://stackoverflow.com/questions/6565357/git-push-requires-username-and-password


代理环境下使用GitHub桌面版

问题
公司所有网络连接都需要通过代理进行,已经设置了IE系统代理,大部分软件都会自动使用系统代理。
GitHub Windows桌面版的安装程序可成功下载安装包,看来是使用了系统代理,安装并打开桌面客户端后,登录自己账号,能读取到自己的repository列表,但clone时会出错。

解决方法
GitHub官方给出了一个解决方法:
http://www.lmxm.net/git/2012/05/21/github-behind-isa-proxy.html

第一步,使用Cntlm屏蔽NTLM代理验证
首先,如果你的网络代理使用的是需要用户名密码的NTLM验证,先安装Cntlm,建立一个无须身份验证的普通HTTP代理,因为目前版本的GIT不支持NTLM验证的代理,不先借助Cntlm屏蔽掉NTLM验证,后续的任何工作都是无意义的。
关于Cntlm的安装和配置请参考:http://blog.csdn.net/bluishglc/article/details/37600773
Cntlm下载地址:https://sourceforge.net/projects/cntlm/

第二步,在.gitconfig文件中配置代理
.gitconfig文件位于C:\Users\usernameC:\Documents and Settings目录中,比如我win7系统是C:\Users\{username}\.gitconfig,打开此文件,在最后加入公司的代理配置:

[http]
    proxy = http://172.17.18.80:8080

Using GitHub for Windows Behind Microsoft ISA Proxy
http://www.lmxm.net/git/2012/05/21/github-behind-isa-proxy.html


上一篇 2015年运动记录表格版

下一篇 MyBatis

阅读
评论
1.3k
阅读预计5分钟
创建日期 2015-12-15
修改日期 2021-03-17
类别

页面信息

location:
protocol:
host:
hostname:
origin:
pathname:
href:
document:
referrer:
navigator:
platform:
userAgent:

评论