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, run git-bash.exe (for a more Unix-like command line) or git-cmd.exe (for Windows command line).
    • for Mac: try to run git --version from Terminal. If git is not installed, you will be prompted to install Xcode Command Line Tools which comes with git 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.

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) or Git-Bash (on Windows)
    1. create a repository under your account online at https://github.com.
    2. Alternatively, you can also fork somebody else’s repository.1
    3. clone (NB: this is done on https://github.com!)
    4. work
    5. add
    6. commit
    7. push / pull
    8. 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 type git branch.
    • NB: sometimes you may get an error, which in most cases means that you need to pull first
  • git pull origin master
  • git log
    • shows the history of commits; here you can choose where you want to roll back, in case of troubles.

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
  • 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

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/

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, where CCXXXXX is the numeric code of the course; LXX is the lesson for which the homework is being submitted; YourLastName is your last name, and YourMatriculationNumber is your matriculation number.

  1. 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