1 of 28

Git and Github

BIOS 611: Introduction to Data Science

Instructor Matt Biggs

2 of 28

Overview of today

  • Make sure to read R4DS Chapter 3 before next class
  • Project demonstration
  • Git and Github (including in-class practice and quiz)

BIOS 611

3 of 28

Objectives

  • Students will get a preview of an example project and practice giving feedback
  • Students will be able to articulate the purpose of git and github
  • Students will install git and practice with basic git functionality

BIOS 611

4 of 28

Demonstration project

Includes the following frameworks:

  • R
    • Tidyverse
    • ggplot
    • Rmd
  • Python
    • Pandas
  • Make
  • Docker

BIOS 611

5 of 28

Demonstration project

  • Input data from the World Bank
  • Python (Pandas library) used to format data
  • R used to generate figures (using Tidyverse and ggplot)
  • Rmd used to generate final HTML file
  • Docker used to make analysis environment reproducible
  • Make used to link all the pieces together reproducibly

BIOS 611

6 of 28

Feedback—essential for improvement

Feedback from peers and clients is the only way you’ll really know if what you’re doing is effective.

Without feedback, you can’t improve and you can’t produce a final product that will be used! Get feedback early and often!

In this course we will heavily emphasize:

  1. Giving effective feedback
  2. Seeking and receiving feedback
  3. Iteration

BIOS 611

7 of 28

Feedback—essential for improvement

Project 1 feedback guidelines:

  • Feedback should be specific—mention specific instances of things that could be improved and suggest specific ways to improve. For example, if a plot doesn’t convey the message well, suggest a better plot type, and explain why it is better.
  • Feedback should be “meta”—help the author think about the audience, the purpose, the conclusions—be thoughtful and give substantive help.
  • Feedback should be respectful and optimistic—do not criticize the author, and help them to recognize what they did well so that they can reinforce what’s working.
  • Feedback should be timely—don’t wait until the last minute. Give feedback soon enough that the author has time to use it.

BIOS 611

8 of 28

Give me some feedback about my demo project!

What are the most important things to improve about the:

  • Plots?
  • Code organization and documentation?
  • Written text?

Let’s discuss some examples as a class.

BIOS 611

9 of 28

Git and Github

Git is a software tool that enables version control and collaboration

BIOS 611

10 of 28

Git and Github

Git is a software tool that enables version control and collaboration.

Why version control?

Why collaboration?

How does it enable collaboration?

BIOS 611

11 of 28

Git and Github

Git is a software tool that enables version control and collaboration

GitHub is a website for code storage. It makes your code (including all changes) visible and accessible from anywhere.

BIOS 611

12 of 28

Git and Github

Git is a software tool that enables version control and collaboration

GitHub is a website for code storage. It makes your code (including all changes) visible and accessible from anywhere.

Why is it important to have backups?

Why is important to make code visible and accessible?

BIOS 611

13 of 28

Git and GitHub

As a data scientist you will use GitHub throughout your career.

You should use Git in graduate school.

Potential employers will look at your GitHub activity.

We will use Git in this class to submit coursework and return project grades.

BIOS 611

14 of 28

BIOS 611

15 of 28

BIOS 611

16 of 28

BIOS 611

17 of 28

BIOS 611

18 of 28

BIOS 611

19 of 28

Branches

Branches allow you to work on a copy of the code that is entirely separate.

No worries about breaking anything!

BIOS 611

20 of 28

Essential Git Commands (and what they mean)

clone - make a local copy of a remote repository

add - track local changes in staging area

commit - record local changes in local repository

push - record local changes in remote repository

pull - pull changes from remote repository to your local repository

status - preview local changes

branch - make a separate copy of the local repository

checkout - change to a specific branch

BIOS 611

21 of 28

Other Git Commands (and what they mean)

There are other git/github topics that we won’t really use in this class, but you will probably encounter:

Pull request - request to merge a branch with master (usually used for collaborate projects, to avoid breaking someone else’s code)

Issues - Ways to track and have conversations around problems in the code

Project boards - Tools for organizing work

BIOS 611

22 of 28

Notes on Git

  • The purpose of git is to track changes in a repository (i.e., version control). Any changes you make to your code using Rstudio can be tracked by Git. You need to add, commit and push your changes often.
  • Git can be confusing if your local copy and the remote (online) copy get out of sync. That is, if the local copy and the remote copy change, then it can be complicated to get things back in sync. It’s much easier to make changes in one place, then synchronize (by pushing or pulling) before making changes in the other place.
  • If you get in a situation where the remote and local repositories are of sync, there are ways to merge and clean it up. But, sometimes it’s easier to just copy your code, delete the repository, and start fresh.

BIOS 611

23 of 28

Notes on Git continued...

  • Github has a file size limit of 100 mb. If you accidentally commit and push a file that’s too big, you’ll get an error. You can fix this using these instructions.

  • RStudio integrates nicely with Git. You are welcome to use that feature, but since we need to use Git for our polyglot projects, I want everyone to learn the more general ways to use Git.

BIOS 611

24 of 28

Github in our classroom

  1. All our course materials are stored on Github: https://github.com/biodatascience/datasci611
    1. Don’t forget to switch to the gh-pages branch!
  2. Github classroom is a tool that creates github repositories for all students in the class, and allows the TAs/graders to view your submissions and return graded material to you

BIOS 611

25 of 28

QUIZ

26 of 28

Install Git and/or Git Desktop

Linux users can easily install git at the command line:

sudo apt-get update�sudo apt-get upgrade�sudo apt-get install git

Windows or Mac users can also install GitHub Desktop

You need to sign up for a GitHub account if you haven’t already.

BIOS 611

27 of 28

In-class exercise: Sharing Feedback with Git

  1. Share Onyen, Github ID and Name with TAs
  2. Use link to start a new, private homework repo in our GitHub Classroom
    1. https://classroom.github.com/a/c1IargKc
  3. In the repo, start a folder called “feedback
  4. Create a text file in the feedback folder called “to_student2_from_student1_test.txt
    • Where “student1” if your github ID and and “student2” is my github ID “mbi2gs
  5. Add some feedback to the file and save it.
    • Remind me to show an example
  6. Git add, commit and push

BIOS 611

28 of 28

In-class exerise: Git-ting Started with Git

First, sign up for a Github account.

There are several ways to make a new repository. The details will be different based on command line or desktop versions of Git. These are the general steps:

  • Create a new, local repository
  • Add a small text file to the repository, add and commit
  • Start a new empty repository on Github, and follow the instructions to connect it to your local repo
  • push to GitHub
  • Check Github for your new content

Bonus learning:

Try editing your code directly on GitHub, then pulling the new version to your local folder

Make and checkout a branch, edit, make pull request and merge, checkout master, then pull

BIOS 611