Week 3: Git & GitHub
1 Links
Lecture pages
- Tuesday – Getting started with Git.
- Thursday – Remotes on GitHub.
- Bonus (optional self-study) content: Branching, collaborating, and undoing.
Exercises & assignments
- Make sure you have done the assignment from week 2 by Tuesday: Create a GitHub account.
- Exercises
You should start thinking about your final project for this course — recall that this is the only part of the course that is graded.
- Take a look at the page with general info on the final project.
- Your proposal (plan) is due on Monday, April 1st (week 5).
- I will also point this out on Tue, and we can talk about this in class if needed on Thursday.
2 Content overview
This week, you will learn about the why and how of using Git version control for your projects, and sharing your code on GitHub.
Be aware that Git is a challenging topic. Therefore, if you can, complete the main reading before Tuesday’s lecture, and also read the Buffalo chapter at some point this week.
A good way to get used to Git is to make dummy repositories where you’re just editing one or a few simple text files with dummy lines of text. That way, you can get used to the basic workflow, and freely experiment also with commands to undo things and move back in time. We’ll do this in our Zoom meetings and I recommend you do it outside of there, too.
Some of the things you will learn this week:
- Understand why you should use a formal Version Control System (VCS) for research projects.
- Learn the basics of the most widely used VCS: Git.
- Learn how to put your local repositories online at GitHub, and how to keep local and online (“remote”) repositories in sync.
- Learn about single-user and multi-user workflows with Git and GitHub.
Optional self-study content:
- Learn how to use Git branches to safely make experimental changes.
- Learn how to undo things and “travel back in time” for your project using Git.
3 Readings
This week’s main reading is the CSB chapter on Git, chapter 2. We will also roughly work our way through this chapter in the Zoom sessions.
The optional reading is the Buffalo chapter on Git, chapter 5. Like the CSB chapter, this starts with the very basics of Git; but it goes a bit further.
There are also some useful further resources mentioned below.
Required readings
- CSB Chapter 2: “Version Control” up until section 2.5 (the rest of the chapter is optional).
Optional readings
- Buffalo Chapter 5: “Git for Scientists”.
Further resources
GitHub has a nice little overview of some Git and GitHub functionality including branching and Pull Requests, and how to do these things in your browser at GitHub.
For some more background on why to use version control, and another perspective on some Git basics, I recommend the article “Excuse me, do you have a moment to talk about version control?” by Jenny Bryan.
Especially if you work with R a lot, I would recommend checking out Happy Git and GitHub for the useR, also by Jenny Bryan. This is a very accessible introduction to Git.
Git-it is a small application to learn and practice Git and GitHub basics.
If you want to try some online exercises with Git with helpful visuals of what Git commands do, try https://learngitbranching.js.org/. (But be aware that this does fairly quickly move to fairly advanced topics, including several that we will not touch on in the course.)