GitHub高级使用记录

时间:2022-07-28
本文章向大家介绍GitHub高级使用记录,主要内容包括其使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

[TOC]

0x00 github API使用

如果自己写的github爬虫没有特色或者没有很高的效率不如使用Github的API,数据获取可以来得快一些。

支持的验证访问方式有如下几种:

  • 未认证 (最高每小时60次访问请求限制)
  • 使用token认证 (每小时5000次的请求)
  • 使用auth认证

API token申请 Settings > Developer settings > Personal access tokens > Generate new token,选择您需要的权限,然后生成新的token;

WeiyiGeek.settings-tokens

Github API使用说明

#查看自己的剩余的次数的地址
https://api.github.com/rate_limit?access_token=a2c312b7523daf22b677434a722bb2ced9b222dc

#查看用户的issues
curl -v -H "Authorization: a2c312b7523daf22b677434a722bb2ced9b222dc" https://api.github.com/user/issues

#用户信息
https://api.github.com/users/weiyigeek
#查看用户粉丝/关注/fork量/星赞/仓库等等
https://api.github.com/users/weiyigeek/{followers,following,fork,starred,repos}

https://api.github.com/search/code?q=keyword&sort=indexed&per_page=100&page=1

0x01 学习遇到配置

仓库建立及初始化
#(1)进行git配置
$ git config --global user.email "[email protected]"
$ git config --global user.name "WeiyiGeek"

#(2)初始化建立仓库并绑定仓库
echo "# SecOpsDev" >> README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin [email protected]:WeiyiGeek/SecOpsDev.git
git push -u origin master

#(3)已存在的仓库绑定新的远程仓库
#push an existing repository from the command line
git remote add origin [email protected]:WeiyiGeek/SecOpsDev.git
git push -u origin master
# git remote add gitee [email protected]:WeiyiGeek/blog.git
# git push -u gitee master -f
自定义域名指向仓库Page

描述:利用自定义的域名通过域名提供商来绑定github page 或 gitee page;

Github Pages:

#Step1.设置自定义域名
Settings > Options > GitHub Pages   

#step2.域名提供商那里的域名管理添加A记录(即github.io页面的)或者CNAME记录(即别名记录)
正在 Ping weiyigeek.github.io [185.199.111.153] 具有 32 字节的数据:
来自 185.199.111.153 的回复: 字节=32 时间=149ms TTL=49

#由于我们github pages自定义域名填写的是www.weiyigeek.github.io,所有需要设置weiyigeek.github.io指向前者;
@ CNAME 默认 www.weiyigeek.github.io.
www CNAME 默认 weiyigeek.github.io.	

#Step3.验证是否解析成功
$dig www.weiyigeek.github.io +noall +answer
DiG 9.11.3-1ubuntu1.7-Ubuntu www.weiyigeek.github.io +noall +answer
global options: +cmd
www.weiyigeek.github.io.     600     IN      CNAME   weiyigeek.github.io.
weiyigeek.github.io.    2458    IN      A       185.199.111.153
weiyigeek.github.io.    2458    IN      A       185.199.109.153
weiyigeek.github.io.    2458    IN      A       185.199.110.153
weiyigeek.github.io.    2458    IN      A       185.199.108.153

![WeiyiGeek.腾讯云域名指向github](https://cdn.jsdelivr.net/gh/WeiyiGeek/blogimage/2019/20190704231409.png

Gitee Pages 描述:由于Gitee是商业与免费版本一起的,只有付费才能使用git pages的自定义域名指向;但是我们还是有其他办法来解决的;

#step1.在域名提供商那里设置	显性URL
blog.weiyigeek.github.io -> weiyigeek.gitee.io.  #自动跳转

WeiyiGeek.设置完成

参考文档:

github仓库信息显示

描述:在网页中显示您的github仓库中项目的start/wathc/fork等等数量; github buttons:https://ghbtns.com/

基础示例:

#type可选 star / watch / fork /Follow
https://ghbtns.com/github-btn.html?user=weiyigeek&repo=weiyigeek.github.io&type=star&count=true

#Star
<iframe src="https://ghbtns.com/github-btn.html?user=weiyigeek&repo=weiyigeek.github.io&type=star&count=true" frameborder="0" scrolling="0" width="170px" height="20px"></iframe>

#Watch
<iframe src="https://ghbtns.com/github-btn.html?user=weiyigeek&repo=weiyigeek.github.io&type=watch&count=true&v=2" frameborder="0" scrolling="0" width="170px" height="20px"></iframe>

#fork 其他类都一样
<iframe src="https://ghbtns.com/github-btn.html?user=twbs&repo=bootstrap&type=fork&count=true" frameborder="0" scrolling="0" width="170px" height="20px"></iframe>

WeiyiGeek.效果图