Joseph Holler's Open GIScience Curriculum at Middlebury College
Sep-14 : In this lesson, we will learn fundamentals of Git version control and publish a website using Markdown, GitHub, and Jekyll.
Thanks to Yifei Luo for contributions to this lesson.
Tuesday, September 19
Git is a free and open source version control system for a repositories.
.gitignore
file instructing Git not to track changes in specified parts of the repository.Git can be run from a command line shell or from a simple GUI (graphical user interface), or from a third-party program. In this course, we will primarily use GitHub’s website https://github.com and GitHub Desktop application.
GitHub is one of many places you can host your Git repositories.
Let’s take a look at QGIS, which is hosted on GitHub.
Clone
: Download a repository (yours or someone else’s) to a local computerFork
: Make a copy of a repository (yours or someone else’s) in your own online GitHub account. This copy may maintain association with the original repository.Commit
: Save a batch of changes to your repository, including a brief message and descriptionRevert
: Undo one or more commits.Push
: Upload one or more commits from the local computer to the GitHub serversFetch origin
: Check whether there are new commits on the GitHub server for this repositoryPull
: Download one or more commits from the GitHub servers to your local computer and merge them into your repository. Or, if you have forked a repository and the original repository has continued to commit revisions, pull
the revisions from the original version into your own forked version. An example case of this: you fork a repository with a course assignment and the professor subsequently makes a last-minute revision to the assignment. Just pull the changes into your own version!Pull Request
: Send suggested commits from your own forked version of a repository to the original repository owner. An example case of this: you fork a version of an open source GIS plugin, fix some errors or make some improvements, and send suggested revisions back to the plugin developer.Markdown is an easy-to-learn and very efficient language for formatting writing. It can be used for writing webpages, blogs, books, computational notebooks, and even scientific articles. Markdown is the language for writing issues, wikis, and readme pages on GitHub.
Using software like Jekyll, you can use Markdown to build websites.
There are two types of GitHub Pages sites.
You can have a user site, where the URL will look like https://<username>.github.io
;
you can also have a project site, where the URL will look like https://<username>.github.io/<repository>
.
In this course, we will create a user site.
We will be using the Jekyll theme Minimal Mistakes, as a simple but highly customizable theme. See documentation and examples here. Feel free to research and apply other themes on your own.
Repository name
to <username>.github.io
. For example, if your GitHub user name is josephholler
, the repository name should be josephholler.github.io
Actions
tab of the site repository, and you should see a pages build and deployment
action. A yellow dot indicates that GitHub is building your site, and a green check mark indicates that GitHub has finished and the site is ready to view.https://josephholler.github.io
You can make simple revisions to your site on GitHub.com.
_pages/about.md
fileCommit
the changes with the green button, providing a message and description of the change.Action
is triggered to rebuild your site every time you commit new changes.F5
key) in order to see the changes.I suggest making more substantial revisions to your site on a local computer.
about.md
file againpreview
button (split window with magnifying glass) at the top right for quick previews of your markdown code. This preview does not render exactly the same way as Jekyll / GitHub sites, but it’s close and saves a lot of trial-and-error time waiting for sites to build.about.md
.
| First Column | Second Column | Last Column |
| :----------- | :-----------: | ----------: |
| left | centered | right |
| empty middle | | empty middle |
First Column | Second Column | Last Column |
---|---|---|
left | centered | right |
empty middle | empty middle |
staged
the changes in a list.diff
of the changes with deletions in red and additions in green.commit
the changes to the local repository.push
the changes.Actions
and when the build is finished, view your website in a web browser.Let’s see how to edit the site content to make it your own.
_config.yml
. This file is YAML code consisting of easily readable keys
followed by a colon and a value
or a list of values denoted by dashes. Long values or lists are indented to indicate that they are part of the preceding key.author
information, which has subkeys for name
, avatar
photo, bio
, and links
to websites and social media sites. You can delete the information for sites you do not use or add information for more sites. You can update the avatar photo by replacing the existing image file. Link icons
are from font awesomeskin
by changing from default
to any from this list. Include the double quotes.Save
, commit
, and push
the changes
.md
files in the _posts
folder all begin with a date in YYYY-MM-DD-post-name.md
format. Let’s leave these here for now, but add a new one along the lines of 2023-09-14-gis-science.md
title
or tags
, but use the same category of capitalized “Blog”---
title: "Is GIS a Science?"
categories:
- Blog
tags:
- science
- GIS
---
/category/title/
. A link to the post 2023-09-14-gis-science.md
with the category Blog
should be [link](/Blog/gis-science/)
Jeckyll looks to an assets
folder for images and other content, so lets create one now.
assets/images
folder, e.g. one of the github logos![GitHub Logo](/assets/images/GitHub-Logo.png)
To see how GitHub works when you are editing with more than one version of a repository, lets return to github.com
about.md
fileFetch origin
History
of your Repository to see the commit
and visualize it’s diff
commit
it.revert changes
fetch
changes from GitHub.com before you start working locally, especially if you use multiple computers.commit
and push
changes when you are finished working locally>100mb
pulled
the most recent commits
staged
changes are committed
together, they are bundled for purposes of pushing
and reverting
. In other words, to undo one of the changes, you must undo them all.commit
frequently, in small packets of changes.push
your latest commits.You can develop a more advanced Jekyll sites customized for portfolios, blogging, documentation, etc. by first forking or cloning a Jekyll template. Some of these work directly with GitHub pages (building the site remotely on GitHub’s servers), while others will require installing requisite software on your own computer to build the site locally. Nearly every aspect of a Jekyll site is customizable by downloading the relevant files from the theme’s GitHub repository into your own site’s repository and modifying them.
Here are some places to start: