Motivation
Same as the raison d’être in Using Octopress on Another Device in Blog 1.
Problem
When I wrote that post last year, I gave too little commands for the actual process of setting up the local repository. Yesterday, I re-read Robert Anderson’s post again, and tried reproducing the steps, and got some redundant Git branches.
My steps
Assume that throughout this post, the current working directoy is
~/octopress
.
$ pwd
/home/owner/octopress
$ git clone -b source git@github.com:VincentTam/vincenttam.github.io.git .
Cloning into '.'...
remote: Counting objects: 71346, done.
remote: Compressing objects: 100% (76/76), done.
remote: Total 71346 (delta 8), reused 0 (delta 0), pack-reused 71266
Receiving objects: 100% (71346/71346), 63.71 MiB | 3.08 MiB/s, done.
Resolving deltas: 100% (33764/33764), done.
Checking connectivity... done.
This is a standard command, and I first created the folder
~/octopress
before cloning the source
branch to the folder, so
that my commands aren’t exactly the same as Anderson’s.
To make another difference, I also fetched the master
branch from
Octopress.
$ git remote add octopress git@github.com:imathis/octopress.git
$ git fetch octopress master
From github.com:imathis/octopress
* branch master -> FETCH_HEAD
* [new branch] master -> octopress/master
$ git branch -av
* source bd39cb2 Corrected the MathJax syntax for X ~ Exp(λ)
remotes/octopress/master 5080107 Fixed improper canonical url
remotes/origin/HEAD -> origin/source
remotes/origin/master 7f8f845 Site updated at 2015-03-08 12:59:04 UTC
remotes/origin/source bd39cb2 Corrected the MathJax syntax for X ~ Exp(λ)
Since I dont’t and won’t have a Mac laptop, I skipped the
command rbenv rehash
.
Source: http://www.homelandsecureit.com/wp-content/uploads/2011/07/MacExplosion.jpg
I then viewed the task setup_github_pages
in Rakefile
, and
discovered that if I cloned the whole remote repository of the
Octopress blog into _deploy
, the there’d be an extra master
branch
in the default deploy directory. To avoid this, I typed a longer
command.
$ gem install bundler
$ bundle install
$ git clone git@github.com:VincentTam/vincenttam.github.io.git -b master _deploy
Cloning into '_deploy'...
remote: Counting objects: 71346, done.
remote: Compressing objects: 68% (52/76) Receiving objects: 0% (1/71346)
remote: Compressing objects: 100% (76/76), done.
remote: Total 71346 (delta 8), reused 0 (delta 0), pack-reused 71266
Receiving objects: 100% (71346/71346), 63.71 MiB | 2.77 MiB/s, done.
Resolving deltas: 100% (33764/33764), done.
Checking connectivity... done.
Checking out files: 100% (644/644), done.
$ cd _deploy && git branch -av && cd ..
* master 7f8f845 Site updated at 2015-03-08 12:59:04 UTC
remotes/origin/HEAD -> origin/source
remotes/origin/master 7f8f845 Site updated at 2015-03-08 12:59:04 UTC
remotes/origin/source bd39cb2 Corrected the MathJax syntax for X ~ Exp(λ)
To test if the last two words of the command in Anderson’s post could be omitted, I changed the Markdown source of one of my old posts slightly, committed the change and pushed it to GitHub.
$ gvim source/_posts/2014-03-16-latex-template-for-essays.markdown
$ git commit -am "Another small minor change" && git push
[source 4be7fba] Another small minor change
1 file changed, 2 insertions(+), 4 deletions(-)
Counting objects: 10, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (5/5), done.
Writing objects: 100% (5/5), 435 bytes | 0 bytes/s, done.
Total 5 (delta 4), reused 0 (delta 0)
To git@github.com:VincentTam/vincenttam.github.io.git
bd39cb2..4be7fba source -> source
$ cd _deploy/ && git branch -av && cd ..
* master 7f8f845 Site updated at 2015-03-08 12:59:04 UTC
remotes/origin/HEAD -> origin/source
remotes/origin/master 7f8f845 Site updated at 2015-03-08 12:59:04 UTC
remotes/origin/source bd39cb2 Corrected the MathJax syntax for X ~ Exp(λ)
$ cd _deploy/ && git pull && git branch -av && cd ..
* master 7f8f845 Site updated at 2015-03-08 12:59:04 UTC
remotes/origin/HEAD -> origin/source
remotes/origin/master 7f8f845 Site updated at 2015-03-08 12:59:04 UTC
remotes/origin/source 4be7fba Another small minor change
From Rakefile
and the above highlighted command output, I could
deduce that before starting to blog on another machine and publish
them to GitHub Pages, one needed to pull the commits from the remote
repository by git pull origin source
and git pull
in ~/octopress
and ~/octopres/_deploy
respectively.
Then I faced the same errors I saw yesterday.1 After solving them, I proceeded to deploying the site to GitHub Pages.
$ rake deploy
...
30 files changed, 44 insertions(+), 46 deletions(-)
## Pushing generated _deploy website
Counting objects: 130, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (64/64), done.
Writing objects: 100% (65/65), 5.37 KiB | 0 bytes/s, done.
Total 65 (delta 35), reused 0 (delta 0)
To git@github.com:VincentTam/vincenttam.github.io.git
7f8f845..5af7b9d master -> master
## Github Pages deploy complete
cd -
Lastly, I found that the remote tracking branch origin/master
wasn’t necessary in ~/octopress
. However, the creation of this
branch couldn’t be avoided: using git clone
to clone either the
whole repository or a single branch only will lead the creation of
all remote branches. To minimize the number of branches in the
local repository for an Octopress blog, I suggest deleting the
outdated origin/master
branch.
$ cd _deploy && git branch -av && cd ..
* master 5af7b9d Site updated at 2015-03-09 06:54:16 UTC
remotes/origin/HEAD -> origin/source
remotes/origin/master 5af7b9d Site updated at 2015-03-09 06:54:16 UTC
remotes/origin/source 4be7fba Another small minor change
$ git branch -av
* source 4be7fba Another small minor change
remotes/octopress/master 5080107 Fixed improper canonical url
remotes/origin/HEAD -> origin/source
remotes/origin/master 7f8f845 Site updated at 2015-03-08 12:59:04 UTC
remotes/origin/source 4be7fba Another small minor change
$ git branch -rd origin/master
Deleted remote branch origin/master (was 7f8f845).
-
See Another Jekyll Error in Blog 1 for details. ↩