Managing this website with Git and Github

Will Overholt bio photo By Will Overholt

While I have some experience playing around with git, I never actually fully incorporated it into my workflows. As this is a skill I want to learn and utilize (I’ve messed up a script so many times in the past and been unable to figure out what the hell I changed) I figured this would be a good venue to start with. I’m in the middle of updating my static html personal website, to one based on Jekyll with a theme provided by Minimal Mistakes (so-simple), and I’m working on new (for me) metagenomic workflows and have written a few summary scripts in this regards.

This entry will likely be read by me every time I add a new blog entry to this website as it concerns hosting both my websites source files, and the production ready site. I followed David Ensinger’s post Deploying Jekyll with Plugins to GitHub Pages to start (nearly verbatium at parts).

##Setting up my Jekyll Page on Github Initializing the git repository.

git init

Create a branch called source (this will be my main jekyll site)

git checkout -b source

Add a .gitignore file to my main site directory containing _site (as recommended by Jekyll).

Delete my old branch “master” (I don’t know if this is necessary)

git branch -D master

Create a new branch “master”

git checkout -b master

Make the default project root of this branch be _site (the static jekyll built site)

git filter-branch --subdirectory-filter _site/ -f

Switch back to the source branch (again this may be unnecessary)

git checkout source

Push all branches (source, master) to origin (my github repository)

git push --all origin

##Updating a development version of the site Make sure I’m working on the development branch

git checkout development

Make changes to files. Best practice to git add & git commit everytime you change something. So frequently use the following commands

git status
git add <file>
git commit -m "message"

Test my local version of the website. I have bundle installed so I run:

bundle exec jekyll serve

##Updating my production site After I’m happy with the content I’ve added and tested on my development site. I checkout my master branch, the merge the development changes. I also do the same with my source branch. This seems very redundant to me and there is likely a better way of doing this!

git checkout master
git merge development

git checkout source
git merge development

git push --all

An easier way to update both master and source from the development.

git checkout development
git pull . development