Skip to content

Commit 643ea59

Browse files
committed
complete 6.4.3 GitHub url shortener.
1 parent 11e79b7 commit 643ea59

3 files changed

Lines changed: 53 additions & 5 deletions

File tree

02-join-github/020-browse-repo.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ GitHub的账户已经建立好了,在建立自己的项目托管之前,看
8080

8181
在文本文件的差异比较中,不但将有差异的行标识出来,还将行内具体改动的字词用特殊颜色进行了标识,不由得感叹GitHub的细致入微。
8282

83-
GitHub还支持对图形文件的差异比较,并提供四种比较方式。在如下地址: http://goo.gl/Gy85b [#]_ 提供了一个示例提交,尝试一下使用不同的图形文件比较方式,查看该提交对图形文件的改动。
83+
GitHub还支持对图形文件的差异比较,并提供四种比较方式。在如下地址: http://git.io/image-diff [#]_ 提供了一个示例提交,尝试一下使用不同的图形文件比较方式,查看该提交对图形文件的改动。
8484

8585
* 默认修改前后的两幅图片左右并排显示,如图2-18所示。
8686

@@ -144,5 +144,5 @@ GitHub还为项目提供图像化报表分析。图2-24是GotGit项目中用到
144144

145145
.. [#] 项目 gotgit 最早由用户 ossxp-com 创建,现已转移到组织 gotgit 账号之下。
146146
.. [#] https://github.com/blog/809-git-dumb-http-transport-to-be-turned-off-in-90-days
147-
.. [#] 短格式URL,实际对应于: https://github.com/cameronmcefee/Image-Diff-View-Modes/commit/8e95f70c9c47168305970e91021072673d7cdad8
147+
.. [#] 短格式URL,实际对应于: https://github.com/cameronmcefee/Image-Diff-View-Modes/commit/8e95f7
148148
.. [#] https://github.com/blog/621-bye-bye-flash-network-graph-is-now-canvas

04-work-with-others/040-code-review.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737

3838
图4-41:提交评注
3939

40-
GitHub还支持Git自身提供的评注功能 [#]_ ,如图4-42所示的是提交 http://goo.gl/ujw5e [#]_ 的评注,这个评注并非通过GitHub添加的,而是由 ``git-note`` 命令提交的评注。这种评注针对一个特定提交只能有一个,GitHub只能显示不能编辑和删除。关于如何通过命令行查看 ``git-note`` 格式的评注,参见《Git权威指南》第570页“41.5 Git评注”。
40+
GitHub还支持Git自身提供的评注功能 [#]_ ,如图4-42所示的是提交 http://git.io/git-notes [#]_ 的评注,这个评注并非通过GitHub添加的,而是由 ``git-note`` 命令提交的评注。这种评注针对一个特定提交只能有一个,GitHub只能显示不能编辑和删除。关于如何通过命令行查看 ``git-note`` 格式的评注,参见《Git权威指南》第570页“41.5 Git评注”。
4141

4242
.. figure:: /images/work-with-others/commit-note-by-git-note.png
4343
:scale: 100
@@ -72,4 +72,4 @@ GitHub还支持Git自身提供的评注功能 [#]_ ,如图4-42所示的是提
7272
----
7373

7474
.. [#] http://www.kernel.org/pub/software/scm/git/docs/git-notes.html
75-
.. [#] 实际地址为 https://github.com/ossxp-com/gitdemo-commit-tree/commit/e80aa7481beda65ae00e35afc4bc4b171f9b0ebf
75+
.. [#] 实际地址为 https://github.com/ossxp-com/gitdemo-commit-tree/commit/e80aa74

06-side-projects/short-url.rst

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,51 @@
1-
GitHub短URL服务
1+
GitHub短网址服务
22
===================
33

4+
在“第2.2节 浏览托管项目”一节介绍图形文件差异比较时,需要给出一个网址,但这个网址很长。如下:
5+
6+
::
7+
8+
https://github.com/cameronmcefee/Image-Diff-View-Modes/commit/8e95f70c9c47168305970e91021072673d7cdad8
9+
10+
很自然地想到了Google短网址服务,于是由上面的长网址生成出一个短小精干的网址: http://goo.gl/Gy85b ,访问该短网址会自动重定向到对应的长网址。
11+
12+
2011年11月,GitHub也推出了自己的短网址服务 [#]_ ,为GitHub自身网址提供短网址转换服务。GitHub短网址服务没有像Google短网址服务那样提供基于Web的图形化转换界面,而是需要用命令行进行网址转换。
13+
14+
例如对于网址 https://github.com/blog/985-git-io-github-url-shortener 的转换,使用 ``curl`` 命令如下操作。
15+
16+
* 将长网址转换为短网址。
17+
18+
命令 ``curl`` 输出中的 ``Location:`` 语句即是转换后的短网址。
19+
20+
::
21+
22+
$ curl -i http://git.io -F 'url=https://github.com/blog/985-git-io-github-url-shortener'
23+
...
24+
HTTP/1.1 201 Created
25+
...
26+
Location: http://git.io/help
27+
28+
* 查看短网址对应的原网址,同样使用 ``curl`` 命令。
29+
30+
命令 ``curl`` 输出302重定向地址即为原始网址。
31+
32+
::
33+
34+
$ curl -i http://git.io/help
35+
HTTP/1.1 302 Found
36+
...
37+
Location: https://github.com/blog/985-git-io-github-url-shortener
38+
39+
为使转换的短网址更易于记忆和识别,可在 ``curl`` 命令中用 code 参数设定期望的短网址。例如下面命令将本节一开始提到的长网址转换为短网址: http://git.io/image-diff 。
40+
41+
::
42+
43+
$ curl -i http://git.io -F 'url=https://github.com/cameronmcefee/Image-Diff-View-Modes/commit/8e95f70c9c47168305970e91021072673d7cdad8' \
44+
-F 'code=image-diff'
45+
...
46+
HTTP/1.1 201 Created
47+
...
48+
Location: http://git.io/image-diff
49+
50+
51+
.. [#] http://git.io/help

0 commit comments

Comments
 (0)