What those three lines do is upload all the changes you have made to the source of your Octopress blog (the Jekyll project) to the source
branch of your GitHub repository (note that this will include everything in the root directory, not just the few files found in the unrelated source
folder).
On the other hand, what rake deploy
does is generate the blog, and upload only the result (all the static HTML pages) to the gh-pages
branch of your GitHub repository (this result is taken from the _public
directory).
Technically, you don't have to upload the source to GitHub, however, it is a great help in case your harddrive fails, or for any reason your information disappears, and you have to rebuild the source from scratch (and I'm pretty sure there is no script which takes a HTML page and "decompiles" it back into _layouts
, _includes
, _posts
, and styles).
Since I usually upload the source at the same time as the result, I have created a Bash script to assist in this (as you say, it takes a minute for it all to run, but I just step aside and do something else in the meantime):
#!/bin/bash
# Load RVM into a shell session *as a function*
# NOTE: Not necessary if you already have a line similar to this in '~/.bash_profile'
[[ -s "/home/andreas/.rvm/scripts/rvm" ]] && source "/home/andreas/.rvm/scripts/rvm"
# Create static site
rake generate
# Publish site to GitHub
rake deploy
# Fetch the optional commit message (as an argument)
if [[ -z "$1" ]]; then
message="Updated source `date`"
else
message="$1";
fi
# Push the changes to 'source' to GitHub
echo ""
echo "## Commit source to GitHub"
git add .
git commit -a -m "$message"
git push origin source
To use it, save it as something like deploy.sh
, and execute it. It takes one optional parameter where you can specify a commit message:
$ deploy.sh "Add blog post 'Why Pandas are going to kill us all'"
If no commit message is provided, it automatically creates a commit message along the lines of Updated source Thu May 8 23:50:14 CDT 2014
.