我以部署到Github为例,Octopress的git仓库(repository)有两个分支,一个叫master,这个是默认的,不能改,被存储在blog根目录的_deploy
文件夹下,是用来存放生成好的blog站点文件的。另一个叫source(名字可以自己定义,此文中指定为source),是用来存放markdown源文件,theme,plugin等用于生成blog所需要的所有文件的。
git branch source //创建本地source分支
git checkout source //切换本地分支到source
git add --all //将所有文件add到source分支
git commit -m "init" //commit
git push origin source //将source分支push到服务器
重新创建一个已经存在的本地Octopress仓库只需要以下几个简单的步骤即可。
首先将博客的源文件clone到本地的octopress文件夹内。
$ git clone -b source git@github.com:username/username.github.com.git octopress
然后将博客文件clone到octopress
的_deploy
文件夹内。
$ cd octopress
$ git clone git@github.com:username/username.github.com.git _deploy
然后安装博客,即bundler和需要的rubygem。
$ gem install bundler
$ rbenv rehash # If you use rbenv, rehash to be able to run the bundle command
$ bundle install
$ rake setup_github_pages # I am not run this command.
如果你设置了自定义域名,需要将根目录的_config.yml
里的url再改成你自己的域名。 这样就建好了一个新的本地仓库了。
当你要在一台电脑写博客或做更改时,首先更新source仓库。更新master并不是必须的,因为你更改源文件之后还是需要rake generate的。
$ cd octopress
$ git pull origin source # update the local source branch
$ cd ./_deploy
$ git pull origin master # update the local master branch
写完博客之后不要忘了推送到remote,下面的步骤在每次更改之后都必须做一遍。
$ rake generate
$ git add .
$ git commit -am "Some comment here."
$ git push origin source # update the remote source branch
$ rake deploy # update the remote master branch
总结起来就是:
source
和master
同步数据 source
分支 rake deploy
(相当于push到远端master分支)