Gangmax Blog

为已经存在的github octopress配置本地环境

在上一篇文章里面,我描述了如何创建一个全新的octopress并部署到github上。本文介绍如何为已经存在于github上的octopress配置本地环境。

  1. 在本地安装RVM(Ruby Version Manager)和Ruby 1.9.2;

  2. 从你的github得到你的octopress内容:

1
2
3
4
5
6
7
git clone -b source https://github.com/username/username.github.com.git octopress # get the source code from your "source" branch of your octopress on github
# learn from: http://stackoverflow.com/questions/1911109/git-clone-a-specific-branch
# You may be prompted to input your github username/password.

cd octopress

git clone https://github.com/username/username.github.com.git _deploy # get your static pages content from your "master"branch of your cotopress on github
  1. 安装依赖gems:
1
2
3
gem install bundler # install bundler gem if you didn't
bundle install # install dependencies
rake install # install the default octopress theme

Added@20130530:

before running the above commands, please make sure you have the following lines in you “~/.bashrc” file, otherwise you will get error “Gem bundler is not installed, run gem install bundler first” when executing “bundle install”:

1
2
3
# Load RVM function
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"
PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting
  1. 编写文章,预览部署:
1
2
3
4
5
cd octopress
rake new_post["your title of your article"]
rake generate # generate your blog static pages content according to your input.
rake preview # start a web server on "http://localhost:4000", you can preview your blog content.
rake deploy # push your static pages content to your github pages repo ("master" branch)
  1. 提交你的文本修改到github:
1
2
3
4
cd your_local_octopress_directory
git add .
git commit -m 'your message'
git push origin source

注意:如果要从github得到最新的source内容,请运行以下命令:

1
2
3
4
5
cd your_local_octopress_directory
cd _deploy
git pull origin master
cd ..
git pull origin source

原则很简单,只要记住“your_local_octopress_directory”对应的是remote source branch,而”_deploy”对应的是remote master branch即可。

Comments