4

I have a dilemma: I have already done rake deploy and my Octopress blog works fine. The documentation says that I have to do another 3 steps:

git add .
git commit -m 'message'
git push origin source

Ok, the first two work great, but the third drives me crazy because the source code on GitHub does not update. Instead, it creates another branch called source which includes all the Octopress source code. Why? Things go just fine if I do rake deploy each time that I have to update my source code. But running this command takes a lot of time for me because I have 300+ blog posts and images.

What can I do?

Sled
  • 16,514
  • 22
  • 110
  • 148
thxou
  • 691
  • 7
  • 19

2 Answers2

2

You can try and follow the article "Octopress: Setting up a Blog and Contributing to an Existing One":

So how does one start contributing to an existing Octopress blog (or yourself from a new computer)? What we want is the same setup as above, but not from scratch.

git clone https://github.com/username/username.github.io.git -b source
cd username.github.com
git clone https://github.com/username/username.github.io.git -b master _deploy
cd ..

The OP ThXou adds:

I understood that if I want to upload my code, I have to do rake deploy each time.


Note that, since April 5th 2013, all username.github.com are now username.github.io.

Community
  • 1
  • 1
VonC
  • 1,042,979
  • 435
  • 3,649
  • 4,283
  • I've read all the article, but I have the same problem than before: all the files in my octopress folder are copied to github, not just the source or _deploy folder. If I do as contributing with the project, i can't run any rake command. – thxou Mar 16 '13 at 16:52
  • Finally I understood that if I want to upload my code, I have to do `rake deploy` each time. Thanks for the article, it helped me a lot. – thxou Mar 29 '13 at 13:22
2

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.

IQAndreas
  • 7,014
  • 4
  • 36
  • 63