@@ -45,58 +45,54 @@ Github Pages有以下几个优点:
45
45
46
46
##配置和使用Github
47
47
48
- Git是版本管理的未来 ,他的优点我不再赘述,相关资料很多。推荐这本[ Git中文教程] ( http://git-scm.com/book/zh ) 。
48
+ git是版本管理的未来 ,他的优点我不再赘述,相关资料很多。推荐这本[ Git中文教程] ( http://git-scm.com/book/zh ) 。
49
49
50
- 要使用Git,需要安装它的客户端,推荐在Linux下使用Git,会比较方便。Windows版的下载地址在这里:[ http://code.google.com/p/msysgit/downloads/list ] ( http://code.google.com/p/msysgit/downloads/list ) 。其他系统的安装也可以参考官方的安装教程。
50
+ 要使用Git,需要安装它的客户端,推荐在Linux下使用Git,会比较方便。下载地址在这里:[ http://code.google.com/p/msysgit/downloads/lis
51
+ ] ( http://code.google.com/p/msysgit/downloads/list ) 。其他系统的安装也可以参考官方的安装教程。
51
52
52
- 下载安装客户端之后,各个系统的配置就类似了,我们使用windows作为例子,Linux和Mac与此类似。
53
+ 安装完成后,还需要最后一步设置,在命令行输入:
53
54
54
- 在Windows下,打开Git Bash,其他系统下面则打开终端(Terminal): Git Bash
55
- ![ Git Bash ] ( /images/images/githubpages/bootcamp_1_win_gitbash.jpg )
55
+ $ git config --global user.name "Your Name"
56
+ $ git config --global user.email "[email protected] "
56
57
57
58
###检查SSH keys的设置
58
59
59
60
首先我们需要检查你电脑上现有的ssh key:
60
- {% highlight java%}
61
+ {% highlight java%}
62
+ $ cd ~ /.ssh
63
+ {% endhighlight %}
61
64
62
- $ c d ~/.ssh
63
-
64
- {% endhighlight %}
65
65
如果显示“No such file or directory”,跳到第三步,否则继续。
66
66
67
67
###备份和移除原来的ssh key设置
68
68
69
69
因为已经存在key文件,所以需要备份旧的数据并删除:
70
- {% highlight Bash shell scripts %}
71
-
72
- $ ls
73
- config id_rsa id_rsa.pub known_hosts
74
- $ mkdir key_backup
75
- $ cp id_rsa* key_backup
76
- $ rm id_rsa*
77
70
78
- {% endhighlight %}
71
+ {% highlight Bash shell scripts %}
72
+ ls
73
+ config id_rsa id_rsa.pub known_hosts
74
+ mkdir key_backup
75
+ cp id_rsa* key_backup
76
+ rm id_rsa*
77
+ {% endhighlight %}
79
78
80
79
###生成新的SSH Key
81
80
82
81
输入下面的代码,就可以生成新的key文件,我们只需要默认设置就好,所以当需要输入文件名的时候,回车就好。
83
82
84
- {% highlight Bash shell scripts%}
85
-
86
- $ ssh-keygen -t rsa -C "邮件地址@youremail.com"
87
- Generating public/private rsa key pair.
88
- Enter file in which to save the key (/Users/ your_user_directory/.ssh/id_rsa):<回车就好>
89
-
90
- {% endhighlight %}
83
+ {% highlight Bash shell scripts%}
84
+ $ ssh-keygen -t rsa -C "邮件地址@youremail .com"
85
+ Generating public/private rsa key pair.
86
+ Enter file in which to save the key (/Users/ your_user_directory/.ssh/id_rsa):<回车就好>
87
+ {% endhighlight %}
91
88
92
89
然后系统会要你输入加密串(Passphrase):
93
90
94
- {% highlight Bash shell scripts%}
95
-
96
- Enter passphrase (empty for no passphrase):<输入加密串 >
97
- Enter same passphrase again:<再次输入加密串>
91
+ {% highlight Bash shell scripts%}
92
+ Enter passphrase (empty for no passphrase):<输入加密串>
93
+ Enter same passphrase again:<再次输入加密串 >
94
+ {% endhighlight %}
98
95
99
- {% endhighlight %}
100
96
最后看到ssh key success,就成功设置ssh key了.
101
97
102
98
###添加SSH Key到GitHub
@@ -124,34 +120,25 @@ PS:如果需要配置多个GitHub账号,可以参看这个[多个github帐
124
120
125
121
如果是下面的反应:
126
122
127
- {% highlight Bash shell scripts%}
128
-
129
123
The authenticity of host 'github.com (207.97.227.239)' can't be established.
130
124
RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.
131
125
Are you sure you want to continue connecting (yes/no)?
132
126
133
- {% endhighlight %}
134
127
135
128
不要紧张,输入yes就好,然后会看到:
136
129
137
- {% highlight Bash shell scripts%}
138
-
139
130
Hi <em>username</em>! You've successfully authenticated, but GitHub does not provide shell access.
140
131
141
- {% endhighlight %}
142
-
143
132
###设置你的账号信息
144
133
145
134
现在你已经可以通过SSH链接到GitHub了,还有一些个人信息需要完善的。
146
135
147
136
Git会根据用户的名字和邮箱来记录提交。GitHub也是用这些信息来做权限的处理,输入下面的代码进行个人信息的设置,把名称和邮箱替换成你自己的,名字必须是你的真名,而不是GitHub的昵称。
148
137
149
- {% highlight Bash shell scripts %}
150
-
151
- $ git config --global user.name "你的名字"
152
- $ git config --global user.email "[email protected] "
153
-
154
- {% endhighlight %}
138
+ {% highlight Bash shell scripts %}
139
+ $ git config --global user.name "你的名字"
140
+ $ git config --global user.email "
[email protected] "
141
+ {% endhighlight %}
155
142
156
143
好了,你已经可以成功连接GitHub了。
157
144
@@ -245,14 +232,12 @@ default.html
245
232
246
233
再次打开Git Bash,先后输入如下命令:
247
234
248
- {% highlight Bash shell scripts %}
249
-
250
- $ git add .
251
- $ git commit -m "first post"
252
- $ git remote add origin https://github.com/username/projectName.git
253
- $ git push origin gh-pages
254
-
255
- {% endhighlight %}
235
+ {% highlight Bash shell scripts %}
236
+ $ git add .
237
+ $ git commit -m "first post"
238
+ $ git remote add origin https://github.com/username/projectName.git
239
+ $ git push origin gh-pages
240
+ {% endhighlight %}
256
241
257
242
据网友反应,如果是初次安装git的话,在commit的时候会提示需要配置username和email,请读者注意根据提示配置一下,至于username和email可以随便填
258
243
@@ -375,24 +360,23 @@ windows的安装还是一如既往的“无脑”,不多说了。
375
360
376
361
config.yml文件实际上是检测系统安装的ruby的位置并记录在这个文件中,以便稍后使用。但上面的命令只针对使用rubyinstall安装的ruby有效,如果是其他方式安装的话,需要手动修改config.yml。我生成的config.yml文件内容如下:(注意路径用的是linux的斜杠方向)
377
362
378
- {% highlight Bash shell scripts %}
379
-
380
- # This configuration file contains the absolute path locations of all
381
- # installed Rubies to be enhanced to work with the DevKit. This config
382
- # file is generated by the 'ruby dk.rb init' step and may be modified
383
- # before running the 'ruby dk.rb install' step. To include any installed
384
- # Rubies that were not automagically discovered, simply add a line below
385
- # the triple hyphens with the absolute path to the Ruby root directory.
386
- #
387
- # Example:
388
- #
389
- # ---
390
- # - C:/ruby19trunk
391
- # - C:/ruby192dev
392
- #
393
- ---
394
- - C:/Ruby193
395
- {% endhighlight %}
363
+ {% highlight Bash shell scripts %}
364
+ # This configuration file contains the absolute path locations of all
365
+ # installed Rubies to be enhanced to work with the DevKit. This config
366
+ # file is generated by the 'ruby dk.rb init' step and may be modified
367
+ # before running the 'ruby dk.rb install' step. To include any installed
368
+ # Rubies that were not automagically discovered, simply add a line below
369
+ # the triple hyphens with the absolute path to the Ruby root directory.
370
+ #
371
+ # Example:
372
+ #
373
+ # ---
374
+ # - C:/ruby19trunk
375
+ # - C:/ruby192dev
376
+ #
377
+ ---
378
+ - C:/Ruby193
379
+ {% endhighlight %}
396
380
397
381
最后,执行如下命令,执行安装:
398
382
@@ -453,7 +437,6 @@ jekyll依赖的组件如下:
453
437
$jekyll --server --safe
454
438
{% endhighlight %}
455
439
456
- ![ ] ( /images/images/githubpages/build-github-blog-page-04-img0.png )
457
440
458
441
jekyll此时会在localhost的4000端口监听http请求,用浏览器访问[ http://localhost:4000/index.html ] ( http://localhost:4000/index.html ) ,之前的页面出现了!
459
442
0 commit comments