github:一些常见问题的解决方法

1.用户头像无法显示的解决方法

访问github经常会出现用户头像无法显示的问题,主要原因可能是:墙内限速,DNS污染,Host设置错误等原因,直接copy头像的URL使用ping命令,也可能无法ping通。

解决方案:通过修改hosts文件,将域名解析直接指向IP地址来绕过DNS的解析,可以解决污染问题。Windows系统中hosts所在文件目录为C:WindowsSystem32driversetc,直接在hosts文件末尾添加以下内容即可,文件修改需要管理员权限。

# GitHub Start 
192.30.253.112 github.com
192.30.253.119 gist.github.com
199.232.28.133 assets-cdn.github.com
199.232.28.133 raw.githubusercontent.com
199.232.28.133 gist.githubusercontent.com
199.232.28.133 cloud.githubusercontent.com
199.232.28.133 camo.githubusercontent.com
199.232.28.133 avatars0.githubusercontent.com
199.232.28.133 avatars1.githubusercontent.com
199.232.28.133 avatars2.githubusercontent.com
199.232.28.133 avatars3.githubusercontent.com
199.232.28.133 avatars4.githubusercontent.com
199.232.28.133 avatars5.githubusercontent.com
199.232.28.133 avatars6.githubusercontent.com
199.232.28.133 avatars7.githubusercontent.com
199.232.28.133 avatars8.githubusercontent.com
# GitHub End

2.本地Git如何管理两个或多个github账号?

每个github账户需要绑定一个基础邮箱,使用对于的基础邮箱生成一个ssh密钥对。配置密钥对后,可以使用Git进行版本控制同时push到github repos上。多个账号需要则对进行操作的仓库地址进行区分。比如:

git@github.com:username/Demo.git 是指默认Git账户对Demo仓库进行操作。

git@other.github.com:username/Demo.git 则是指other对应的git账户对Demo仓库进行操作

3.如何进行pull request

  • 对想要pr的repository进行fork到自己账号
  • 然后将repository clone到本地,进行代码创作,之后进行add和commit操作(和提交到自己仓库的操作相同)
  • 进入github对应的参考,点击New pull request,然后到了compare changes页面,查看一下相关信息,点击Create pull request,(添加相关说明)即可
  • 最后只用等待内容被merge就行

4.解决Git clone太慢的方法

由于墙内限速,github特别慢,除了页面刷新有很长的时间延迟,就连git clone操作都经常会over time挂掉。可以借助码云(国内代码托管网站)解决问题。具体操作是:

  • 复制你要clone的代码仓库的URL,使用码云的从github/gitlab导入仓库功能
  • 从URL导入,粘贴之前的URL,点击导入按钮,等系统转换刷新即可
  • 然后从码云中,将代码仓库clone下来或者直接下载,速度会很快。

这方法虽然麻烦了一些,但在非常之时还是很有用的。

原文地址:https://www.cnblogs.com/microbit1024/p/12468949.html