3 Lesson 03
3.1 Version Control and Collaboration
Version control systems are extremely helpful for the development of DH projects, which are often lengthy and complex and require organic collaboration. Git
and GitHub
are currently the most popular tools of this kind. It is difficult to imagine a DH project that would not rely on the use of git
and GitHub
.
Before we begin, make sure to:
- Create a github account at https://github.com/, if you do not have one yet.
- Download and install
git
software:- for Windows:
- you can download it from https://git-scm.com/download/win. Please, choose 64-bit Git for Windows Setup.
- you can also install a portable version of
git
which does not require installation https://git-scm.com/download/win. For this, choose 64-bit Git for Windows Portable. Simply download and unzip (Suggestion: move that unzipped folder to the folder where you keep all class-related files and materials). In the folder, rungit-bash.exe
(for a more Unix-like command line) orgit-cmd.exe
(for Windows command line).
- you can also install a portable version of
- you can download it from https://git-scm.com/download/win. Please, choose 64-bit Git for Windows Setup.
- for Mac: try to run
git --version
from Terminal. Ifgit
is not installed, you will be prompted to installXcode Command Line Tools
which comes withgit
among other things. This is the easiest way. - Note: there are also interface tools for github. We will not be working with them in the class, but you are welcome to test them on your own at home. See, https://desktop.github.com. The main reason for this is because interface tools will be different for different operating systems, while the command line usage will be exactly the same across all platforms.
- for Windows:
In class we will cover the following:
- Basic
git
functionality; - Starting a
github
-based website; - Basics of
markdown
;
3.2 Setting-up git
git config --global user.name "YourName"
git config --global user.email "YourEmail"
3.3 General git
workflow
- In
Terminal
(on Mac) orGit-Bash
(on Windows)- create a repository under your account online at https://github.com.
- Alternatively, you can also
fork
somebody else’s repository.1 clone
(NB: this is done on https://github.com!)- work
add
commit
push
/pull
- send
pull request
(NB: this is done on https://github.com)
Note: Steps 2 and 8 are relevant only when you work on a project (repository) that is owned by somebody else. If you work on a repository that you created under your account, you only need steps 1, 3-7. Below is a visual representation of this cycle.
3.4 Main git
Commands
git clone <link>
- clones/downloads a repository on you machine
git status
- shows the current status of the repository (new, changed, deleted)
git add .
- adds all new files and modified files to the repository
git commit -m "message"
- saves all files in their current state into the repository, and created a milestone
git push origin master
- uploads changes to https://github.com
origin
is a specific repository you are pushing your changes to; it is automatically set up, when you clone a repository on your computer.master
is the branch you are pushing to the repository;master
is the default name of the main branch in a git repository. To check the names of your branches, you can typegit branch
.- NB: sometimes you may get an error, which in most cases means that you need to
pull
first
git pull origin master
- downloads changes from https://github.com
git log
- shows the history of
commit
s; here you can choose where you want to roll back, in case of troubles.
- shows the history of
3.5 Some useful command line commands to remember
pwd
- shows you where you are on a drive (gives you path)
ls
/dir
[on Windows]- shows everything in the your current location/folder
cd <name of the folder>
- takes you to that folder
cd ..
- takes you one level up in the tree structure of your computer
3.6 Practice
- Under your GitHub account, create repository
HW070172
; - clone it to your computer (use command line:
git clone LinkToYourRepository
); - Now, in the repository:
- let’s edit
README.md
(create it, if you have not yet); add some text into this file - create subfolders for Lessons, like
L01
,L02
,L03
, etc. - copy/paste your homework files in respective subfolders.
- Now, do the
add
-commit
-push
routine to upload the files to your repository
- let’s edit
- Now, online:
- check if your files are there
- let’s do some edits to the
README.md
file (markdown basics / github flavor)
pull
/push
3.7 Homework
Git and GitHub
- Watch a video on
Git & GitHub
in Dr. Vierthaler’s Hacking the Humanities series: Supplement 1: A quick Git and Github Tutorial. This will help you to go over the new material and pick up a few more usefulgit
&gitHub
tricks. - There is an interface for github that you can also use, but I strongly recommend to use command line; interfaces change, but commandline commands remain the same!
- Daniel van Strien. 2016. “An Introduction to Version Control Using GitHub Desktop,” The Programming Historian 5, https://programminghistorian.org/.
- Please, also read (for
markdown
): Simpkin, Sarah. 2015. “Getting Started with Markdown.” Programming Historian, November. https://programminghistorian.org/.- More on github-flavored
markdown
: https://guides.github.com/features/mastering-markdown/. - On
markdown
for academic writing, see https://pandoc.org/MANUAL.html. - A cheat-sheet & interactive tutorial for your practice: https://commonmark.org/help/.
- More on github-flavored
Extra: you can build and host a website on github.com
; your website will have the name: YourUserName.github.io
— you can create a repository with that name and build your website there using Jekyll and GitHub Pages. Any other repository may also be converted into a part of your website, which will be accessible at YourUserName.github.io/YourRepository/
- Visconti, Amanda. 2016. “Building a Static Website with Jekyll and GitHub Pages.” Programming Historian, April. https://programminghistorian.org/.
Python
- Work through Chapter II of Zelle’s book; read the entire chapter; retype and run all code snippets as described in the book; work through the chapter summary and exercises; complete all programming exercises;
- Watch Dr. Vierthaler’s videos:
- Episode 04: Strings;
- Episode 05: Integers, Floats, and Math in Python;
- Episode 06: Lists
Submitting homework
- Homework assignment must be submitted by the beginning of the next class;
- Now, that you know how to use GitHub, you will be submitting your homework pushing it to github:
- Create a relevant subfoler in your
HW070172
repository and place your HW files there; push them to your GitHub account;- Email me the link to your repository with a short message (Something like: I have completed homework for Lesson 3, which is uploaded to my repository … in subfolder
L03
) - In the subject of your email, please, add the following:
CCXXXXX-LXX-HW-YourLastName-YourMatriculationNumber
, whereCCXXXXX
is the numeric code of the course;LXX
is the lesson for which the homework is being submitted;YourLastName
is your last name, andYourMatriculationNumber
is your matriculation number.
- Email me the link to your repository with a short message (Something like: I have completed homework for Lesson 3, which is uploaded to my repository … in subfolder
- Create a relevant subfoler in your
NB: this is done on https://github.com); forking means creating your own copy of some one’s repository at that specific moment in time↩