实用的GitHub小技巧

收集一些关于使用GitHub的实用的小技巧(持续更新...)

利用GitHub上的GitHub Pages功能搭建静态网站

如何用github和hexo搭建个人博客

GitHub Pages官方介绍及文档

精准分享代码

方法:url后加上

  • #L行号(分享某一行代码)

  • #L开始行号-#L结束行号(分享多行代码)

示例:

通过HTML方式嵌入GitHub项目star等按钮

方法:

  • Star:

<iframe src="https://ghbtns.com/github-btn.html?user=twbs&repo=bootstrap&type=star&count=true&size=large" frameborder="0" scrolling="0" width="160px" height="30px"></iframe>

<iframe src="https://ghbtns.com/github-btn.html?user=twbs&repo=bootstrap&type=star&count=true" 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&size=large" frameborder="0" scrolling="0" width="158px" height="30px"></iframe>

<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>
  • Watch:

<iframe src="https://ghbtns.com/github-btn.html?user=twbs&repo=bootstrap&type=watch&count=true&size=large&v=2" frameborder="0" scrolling="0" width="160px" height="30px"></iframe>

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

<iframe src="https://ghbtns.com/github-btn.html?user=mdo&type=follow&count=true&size=large" frameborder="0" scrolling="0" width="220px" height="30px"></iframe>

<iframe src="https://ghbtns.com/github-btn.html?user=mdo&type=follow&count=true" frameborder="0" scrolling="0" width="170px" height="20px"></iframe>
  • 将user和repo改为自己GitHub用户名和仓库名就OK

官方介绍: http://ghbtns.com/

查看项目的访问数据

Graphs其他功能介绍: Introducing the New GitHub Graphs

trending显示各类语言项目每日的排行榜,非常适合开发者fork学习。

方法:

提示:右侧可以切换语言。

显示快捷键

方法: 任意界面“shift”+“?”可以显示快捷键。

issue快速引用

方法: 选中文字,按“R”键快速引用。

issue添加表情

方法: 输入冒号“:”添加表情。

更改项目语言

通常GitHub会根据项目相关文件代码的数量来自动识别你的项目是什么语言类型的项目。

方法:

  1. 在项目根目录添加.gitattributes文件;

  2. 文件内容如下:

*.githublang linguist-language=truelang

示例:

*.js linguist-language=go
*.css linguist-language=go
*.html linguist-language=go

原理: 将.js,.css,.html文件识别成go语言。


(后续有新的小技巧再慢慢补充...)

Last updated