當我們需要在不同的電腦上來對同一個Octopress博客進行維護的時候就需要針對已存在的Octopress來設置環境了,
安裝相應的軟件
- Git:http://msysgit.googlecode.com/files/Git-1.8.1.2-preview20130201.exe
- Ruby:http://files.rubyforge.vm.bytemark.co.uk/rubyinstaller/rubyinstaller-1.9.3-p429.exe
- DevKit:http://cloud.github.com/downloads/oneclick/rubyinstaller/DevKit-tdm-32-4.5.2-20111229-1559-sfx.exe
- Python:http://www.python.org/ftp/python/2.7.5/python-2.7.5.msi
關於軟件的安裝在《Windows下搭建Octopress博客》中有詳細的介紹。
拉Octopress代碼到本地
使用下面命令將已存在的Octopress代碼拉到本地
git clone -b source [email protected]:oec2003/oec2003.github.com.git
git clone [email protected]:oec2003/oec2003.github.com.git _deploy
編寫文章
cd Octopress
rake new_post['new post title']
rake generate
rake preview
rake deploy
推送到github
cd Octopress
git add .
git commit -m 'message'
git push origin source
從github上獲取最新
比如在公司發佈了一篇博文,回到家裏想繼續發博文,就需要先將github上的最新代碼拉到本地:
cd Octopress
cd _deploy
git pull origin master
cd ..
git pull origin source
今天在家裏的另一臺電腦上進行生成文章時,發現當執行了命令rake generate
後,生成到public目錄中相應的頁面爲空,沒有任何內容,但在命令行中命令還是正常執行了,沒有出現異常。最後查出原因是因爲Python的安裝目錄沒有添加到環境變量中。所以建議在準備環境時就就將git、ruby、python的安裝目錄都添加到環境變量中。