GitHub 你们常上吧?但是使用 GitHub 的各类小窍门你就不必定知道了。本文将各类使用 GitHub 的小窍门分享给你们。git
有些修改只是增减了空格,在URL中添加?w=1
就能够忽略。github
在URL中添加?author=username
,例如:segmentfault
https://github.com/rails/rails/commits/master?author=dhh
使用相似以下的URL比较分支:curl
https://github.com/rails/rails/compare/master...4-1-stable
一样可使用一下格式:网站
https://github.com/rails/rails/compare/master@{1.day.ago}...master https://github.com/rails/rails/compare/master@{2014-10-04}...master
若是想和派生仓库比较,加上派生仓库名做前缀便可:ui
https://github.com/rails/rails/compare/byroot:master...master
Gists是 GitHub 推出的基于 Git 的代码片断服务。Gists页面提供JavaScript代码,能够将 Gist 嵌入到其余站点。可是不少站点粘贴 JavaScript 无效,这时候你能够在 Gist URL 后附加.pibb
,获得一个纯 HTML 的版本,而后就能够复制粘贴 HTML 源码到其余网站了。例如 https://gist.github.com/tiimgreen/10545817.pibburl
Git.io 是适用于 GitHub 的短网址服务。spa
固然,为了逼格方便,也可使用Curl访问:code
$ curl -i http://git.io -F "url=https://github.com/..." HTTP/1.1 201 Created Location: http://git.io/abc123 $ curl -i http://git.io/abc123 HTTP/1.1 302 Found Location: https://github.com/...
你甚至能够指定短网址的字段:ip
$ curl -i http://git.io -F "url=https://github.com/technoweenie" \ -F "code=t" HTTP/1.1 201 Created Location: http://git.io/t
例如,在 URL 中加上 #L52
能够高亮第52行。或者你也能够直接点击行数。
多行高亮一样支持。你可使用相似#L53-L60
格式,或者在按住shift的同时点击。
https://github.com/rails/rails/blob/master/activemodel/lib/active_model.rb#L53-L60
你能够选中别人的评论文字,而后按r
,这些内容会以引用的形式被复制在文本框中:
在工单或合并请求中,你可使用任务列表语法:
- [ ] Be awesome - [ ] Do stuff - [ ] Sleep
勾选以后,会更新 Markdown:
- [x] Be awesome - [x] Do stuff - [ ] Sleep
能够在 URL 后添加 .diff
和 .patch
,以对应的模式查看合并请求:
https://github.com/tiimgreen/github-cheat-sheet/pull/15 https://github.com/tiimgreen/github-cheat-sheet/pull/15.diff https://github.com/tiimgreen/github-cheat-sheet/pull/15.patch
结果是纯文本的:
diff --git a/README.md b/README.md index 88fcf69..8614873 100644 --- a/README.md) +++ b/README.md @@ -28,6 +28,7 @@ All the hidden and not hidden features of Git and GitHub. This cheat sheet was i - [Merged Branches](#merged-branches) - [Quick Licensing](#quick-licensing) - [TODO Lists](#todo-lists) +- [Relative Links](#relative-links) - [.gitconfig Recommendations](#gitconfig-recommendations) - [Aliases](#aliases) - [Auto-correct](#auto-correct) @@ -381,6 +382,19 @@ When they are clicked, they will be updated in the pure Markdown: - [ ] Sleep (...)