Skip to content

Commit 4695db5

Browse files
committed
modify github pages
1 parent a2c0388 commit 4695db5

File tree

1 file changed

+52
-69
lines changed

1 file changed

+52
-69
lines changed

_posts/2015-03-01-github-pages-blog.md

Lines changed: 52 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -45,58 +45,54 @@ Github Pages有以下几个优点:
4545

4646
##配置和使用Github
4747

48-
Git是版本管理的未来,他的优点我不再赘述,相关资料很多。推荐这本[Git中文教程](http://git-scm.com/book/zh)
48+
git是版本管理的未来,他的优点我不再赘述,相关资料很多。推荐这本[Git中文教程](http://git-scm.com/book/zh)
4949

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)。其他系统的安装也可以参考官方的安装教程。
5152

52-
下载安装客户端之后,各个系统的配置就类似了,我们使用windows作为例子,Linux和Mac与此类似。
53+
安装完成后,还需要最后一步设置,在命令行输入:
5354

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]"
5657

5758
###检查SSH keys的设置
5859

5960
首先我们需要检查你电脑上现有的ssh key:
60-
{% highlight java%}
61+
{% highlight java%}
62+
$ cd ~/.ssh
63+
{% endhighlight %}
6164

62-
$ c d ~/.ssh
63-
64-
{% endhighlight %}
6565
如果显示“No such file or directory”,跳到第三步,否则继续。
6666

6767
###备份和移除原来的ssh key设置
6868

6969
因为已经存在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*
7770

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 %}
7978

8079
###生成新的SSH Key
8180

8281
输入下面的代码,就可以生成新的key文件,我们只需要默认设置就好,所以当需要输入文件名的时候,回车就好。
8382

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 %}
9188

9289
然后系统会要你输入加密串(Passphrase):
9390

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 %}
9895

99-
{% endhighlight %}
10096
最后看到ssh key success,就成功设置ssh key了.
10197

10298
###添加SSH Key到GitHub
@@ -124,34 +120,25 @@ PS:如果需要配置多个GitHub账号,可以参看这个[多个github帐
124120

125121
如果是下面的反应:
126122

127-
{% highlight Bash shell scripts%}
128-
129123
The authenticity of host 'github.com (207.97.227.239)' can't be established.
130124
RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.
131125
Are you sure you want to continue connecting (yes/no)?
132126

133-
{% endhighlight %}
134127

135128
不要紧张,输入yes就好,然后会看到:
136129

137-
{% highlight Bash shell scripts%}
138-
139130
Hi <em>username</em>! You've successfully authenticated, but GitHub does not provide shell access.
140131

141-
{% endhighlight %}
142-
143132
###设置你的账号信息
144133

145134
现在你已经可以通过SSH链接到GitHub了,还有一些个人信息需要完善的。
146135

147136
Git会根据用户的名字和邮箱来记录提交。GitHub也是用这些信息来做权限的处理,输入下面的代码进行个人信息的设置,把名称和邮箱替换成你自己的,名字必须是你的真名,而不是GitHub的昵称。
148137

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 %}
155142

156143
好了,你已经可以成功连接GitHub了。
157144

@@ -245,14 +232,12 @@ default.html
245232

246233
再次打开Git Bash,先后输入如下命令:
247234

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 %}
256241

257242
据网友反应,如果是初次安装git的话,在commit的时候会提示需要配置username和email,请读者注意根据提示配置一下,至于username和email可以随便填
258243

@@ -375,24 +360,23 @@ windows的安装还是一如既往的“无脑”,不多说了。
375360

376361
config.yml文件实际上是检测系统安装的ruby的位置并记录在这个文件中,以便稍后使用。但上面的命令只针对使用rubyinstall安装的ruby有效,如果是其他方式安装的话,需要手动修改config.yml。我生成的config.yml文件内容如下:(注意路径用的是linux的斜杠方向)
377362

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 %}
396380

397381
最后,执行如下命令,执行安装:
398382

@@ -453,7 +437,6 @@ jekyll依赖的组件如下:
453437
$jekyll --server --safe
454438
{% endhighlight %}
455439

456-
![](/images/images/githubpages/build-github-blog-page-04-img0.png)
457440

458441
jekyll此时会在localhost的4000端口监听http请求,用浏览器访问[http://localhost:4000/index.html](http://localhost:4000/index.html),之前的页面出现了!
459442

0 commit comments

Comments
 (0)