鲜为人知的 GitHub 使用技巧

系统
GitHub 大家常上吧?可是使用 GitHub 的各种小窍门你就不一定知道了。本文将各种使用 GitHub 的小窍门分享给大家。

 GitHub 大家常上吧?可是使用 GitHub 的各种小窍门你就不一定知道了。本文将各种使用 GitHub 的小窍门分享给大家。

 

[[111980]]

diff时忽略空格

有些修改只是增减了空格,在URL中添加?w=1就可以忽略。

查看某个作者的提交历史

在URL中添加?author=username,例如:

  1. https://github.com/rails/rails/commits/master?author=dhh 

比较版本

使用类似如下的URL比较分支:

  1. https://github.com/rails/rails/compare/master...4-1-stable 

同样可以使用一下格式:

  1. https://github.com/rails/rails/compare/master@{1.day.ago}...master 
  2. https://github.com/rails/rails/compare/master@{2014-10-04}...master 

如果想和派生仓库比较,加上派生仓库名作前缀即可:

  1. https://github.com/rails/rails/compare/byroot:master...master 

通过 HTML 方式嵌入 Gist

Gists是 GitHub 推出的基于 Git 的代码片段服务。Gists页面提供JavaScript代码,可以将 Gist 嵌入到其他站点。但是很多站点粘贴 JavaScript 无效,这时候你可以在 Gist URL 后附加.pibb,得到一个纯 HTML 的版本,然后就可以复制粘贴 HTML 源码到其他网站了。例如 https://gist.github.com/tiimgreen/10545817.pibb

Git.io

Git.io 是适用于 GitHub 的短网址服务。

当然,为了方便,也可以使用Curl访问:

  1. $ curl -i http://git.io -F "url=https://github.com/..." 
  2. HTTP/1.1 201 Created 
  3. Location: http://git.io/abc123 
  4.   
  5. $ curl -i http://git.io/abc123 
  6. HTTP/1.1 302 Found 
  7. Location: https://github.com/... 

你甚至可以指定短网址的字段:

  1. $ curl -i http://git.io -F "url=https://github.com/technoweenie" \ 
  2.     -F "code=t
  3. HTTP/1.1 201 Created 
  4. Location: http://git.io/t 

高亮行

例如,在 URL 中加上 #L52 可以高亮第52行。或者你也可以直接点击行数。

多行高亮同样支持。你可以使用类似#L53-L60格式,或者在按住shift的同时点击。

  1. https://github.com/rails/rails/blob/master/activemodel/lib/active_model.rb#L53-L60 

快速引用

你可以选中别人的评论文字,然后按r,这些内容会以引用的形式被复制在文本框中:

任务列表

在工单或合并请求中,你可以使用任务列表语法:

  1. - [ ] Be awesome 
  2. - [ ] Do stuff 
  3. - [ ] Sleep 

勾选之后,会更新 Markdown:

  1. - [x] Be awesome 
  2. - [x] Do stuff 
  3. - [ ] Sleep 

合并请求的 diff 和 patch

可以在 URL 后添加 .diff 和 .patch,以对应的模式查看合并请求:

  1. https://github.com/tiimgreen/github-cheat-sheet/pull/15 
  2. https://github.com/tiimgreen/github-cheat-sheet/pull/15.diff 
  3. https://github.com/tiimgreen/github-cheat-sheet/pull/15.patch 

结果是纯文本的:

  1. diff --git a/README.md b/README.md 
  2. index 88fcf69..8614873 100644 
  3. --- a/README.md) 
  4. +++ b/README.md 
  5. @@ -28,6 +28,7 @@ All the hidden and not hidden features of Git and GitHub. This cheat sheet was i 
  6.  - [Merged Branches](#merged-branches) 
  7.  - [Quick Licensing](#quick-licensing) 
  8.  - [TODO Lists](#todo-lists) 
  9. +- [Relative Links](#relative-links) 
  10.  - [.gitconfig Recommendations](#gitconfig-recommendations) 
  11.      - [Aliases](#aliases) 
  12.      - [Auto-correct](#auto-correct) 
  13. @@ -381,6 +382,19 @@ When they are clicked, they will be updated in the pure Markdown: 
  14.  - [ ] Sleep 
  15.   
  16. (...) 

编撰 SegmentFault
参考 github-cheat-sheet 

via : http://segmentfault.com/a/1190000000475547 

责任编辑:黄丹 来源: segmentfault.com
相关推荐

2022-05-30 09:01:13

CSS技巧前端

2023-04-23 15:11:26

2019-12-12 20:49:05

JavaScript语言运算符

2024-03-04 16:32:02

JavaScript运算符

2009-03-05 09:48:25

查询技巧MySQL

2019-11-20 10:54:32

Python数据结构数据库

2010-01-07 10:05:51

IT顾问特质

2016-05-03 10:19:04

H5技巧干货

2011-05-03 13:13:52

编程PHPJava

2019-12-06 14:30:41

GNU调试器GDB修复代码

2009-07-09 17:38:35

2014-07-29 14:25:43

Unix命令

2009-09-14 09:45:20

Chrome谷歌操作系统

2019-10-08 16:24:33

Chrome浏览器

2017-11-08 14:55:16

Linux命令sudo

2015-06-09 11:12:31

Swift语言Swift特性

2015-08-18 10:57:52

机房制冷数据中心

2016-06-07 09:23:05

浏览器技巧快捷键

2010-03-23 16:53:19

Visual Stud

2009-02-09 09:16:28

热键自注销漏洞
点赞
收藏

51CTO技术栈公众号