GitHub的部分使用技巧

本文列举了一些GitHub使用上的小技巧

[size=large][b]diff时忽略空格[/b][/size]
有些修改只是增减了空格,在URL中添加[color=red]?w=1[/color]就可以忽略。
[img]http://dl2.iteye.com/upload/attachment/0099/0010/2ff27f52-1160-3ee9-b769-218f06ed4b63.png[/img]


[b][size=large]查看某个作者的提交历史[/size][/b]
在URL中添加[color=red]?author=username[/color],例如:
https://github.com/rails/rails/commits/master?author=dhh

[img]http://dl2.iteye.com/upload/attachment/0099/0012/545c179f-c4bc-3fc5-8ff9-96fd433be13e.png[/img]


[size=large][b]比较版本[/b][/size]
使用类似如下的URL比较分支:
https://github.com/rails/rails/compare/master...4-1-stable


[img]http://dl2.iteye.com/upload/attachment/0099/0014/8d20f58f-0bfc-3360-8c84-cfcc7bbccadf.png[/img]

同样可以使用一下格式:

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

如果想和派生仓库比较,加上派生仓库名作前缀即可:
https://github.com/rails/rails/compare/byroot:master...master


[b][size=large]通过 HTML 方式嵌入 Gist[/size][/b]

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


[b][size=large]Git.io[/size][/b]

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

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

$ 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/...


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

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


[img]http://dl2.iteye.com/upload/attachment/0099/0016/ff728049-5acd-3c34-913f-04ffade49bd4.png[/img]


[size=large][b]高亮行[/b][/size]

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

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

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


[img]http://dl2.iteye.com/upload/attachment/0099/0018/e08e6c6e-0da1-33d5-b5c0-0953988d9dc5.png[/img]


[b][size=large]快速引用[/size][/b]

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

[img]http://dl2.iteye.com/upload/attachment/0099/0020/91c30f79-f46e-3ddb-aabf-8e5b58be49ca.gif[/img]


[b][size=large]任务列表[/size][/b]

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

- [ ] Be awesome
- [ ] Do stuff
- [ ] Sleep



[img]http://dl2.iteye.com/upload/attachment/0099/0022/337c38f4-c626-32b2-9ccc-eac9fc04d14e.png[/img]

勾选之后,会更新 Markdown:

- [x] Be awesome
- [x] Do stuff
- [ ] Sleep

合并请求的 diff 和 patch

可以在 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

(...)


[b][size=large]GitHub快捷键[/size][/b]
常用的快捷键如 t, w, s
这些快捷键能执行那些操作,大家在任意一个repository上试试就知道啦
如果要查看所有的快捷键,可以在键盘上按下 ?
全部快捷键如下:

[img]http://dl2.iteye.com/upload/attachment/0099/0024/a6b00c9a-82f4-3455-a839-7e3d16b899fc.png[/img]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值