Version control is a game changer; or how I learned to love git/GitHub
Before class, you can prepare by reading the following materials:
dsbook
from Rafael IrizarryMaterial for this lecture was borrowed and adopted from
At the end of this lesson you will:
This document gives a brief explanation of GitHub and how we will use it for this course.
Git is what is called a version control system for file management. The main idea is that as you (and your collaborators) work on a project, the software tracks, and records any changes made by anyone.
GitHub is a hosting service on internet for git-aware folders and projects
Since we will only be using Git through GitHub, I tend to not distinguish between the two. In the following, I refer to all of it as just GitHub. Note that other interfaces to Git exist, e.g., Bitbucket, but GitHub is the most widely used one.
You want to use GitHub to avoid this:
GitHub gives you a clean way to track your projects. It is also very well suited to collaborative work. Historically, version control was used for software development. However, it has become broader and is now used for many types of projects, including data science projects.
To learn a bit more about Git/GitHub and why you might want to use it, read this article by Jenny Bryan.
Note her explanation of what’s special with the README.md
file on GitHub.
GitHub is ideal if you have a project with a fair number of files, most of those files are text files (such as code, LaTeX, (R)markdown, etc.) and different people work on different parts of the project.
GitHub is less useful if you have a lot of non-text files (e.g. Word or Powerpoint) and different team members might want to edit the same document at the same time. In that instance, a solution like Google Docs, Word+Dropbox, Word+Onedrive, etc. might be better.
Git and GitHub is fundamentally based on commands you type into the command line. Lots of online resources show you how to use the command line. This is the most powerful, and the way I almost always interact with git/GitHub. However, many folks find this the most confusing way to use git/GitHub. Alternatively, there are graphical interfaces.
Note: As student, you can (and should) upgrade to the Pro version of GitHub for free (i.e. access to unlimited private repositories is one benefit), see the GitHub student developer pack on how to do this.
One of my favorite resources for getting started with git/GitHub is the Happy Git with R from Jenny Bryan:
It truly is one of the best resources out there for getting started with git/GitHub, especially with the integration to RStudio. Therefore, at this point, I will encourage all of you to go read through the online book.
Some of you may only need to skim it, others will need to spend some time reading through it. Either way, I will bet that you won’t regret the time investment.
In this course, you will use git/GitHub in the following ways:
git add
, git commit
, git push
, git pull
, etc) .Learning these skills will be useful down the road if you ever work collaboratively on a project (i.e. writing code as a group). In this scenario, you will use the skills you have been practicing in your projects to work together as a team in a single GitHub repository.
Here are some post-lecture questions to help you think about the material discussed.
Questions:
What is version control?
What is the difference between git and GitHub?
What are other version controls software/tools that are available besides git?
dsbook
by Rafael Irizarry.
Text and figures are licensed under Creative Commons Attribution CC BY-NC-SA 4.0. The figures that have been reused from other sources don't fall under this license and can be recognized by a note in their caption: "Figure from ...".
For attribution, please cite this work as
Hicks (2021, Aug. 31). Statistical Computing: Introduction to git/GitHub. Retrieved from https://stephaniehicks.com/jhustatcomputing2021/posts/2021-08-31-introduction-to-gitgithub/
BibTeX citation
@misc{hicks2021introduction, author = {Hicks, Stephanie}, title = {Statistical Computing: Introduction to git/GitHub}, url = {https://stephaniehicks.com/jhustatcomputing2021/posts/2021-08-31-introduction-to-gitgithub/}, year = {2021} }