7 RDD: Quick Starting with Github
One of the goals for this course is to familiarize yourself with Git and GitHub. This section is a concise version of a more detailed document you’ll find later in the class, combining insights from GitHub Classroom’s github-starter-course and Jenny Bryan’s happygitwithr. I strongly encourage you to check out the unabridged version of happygit as it has so much more detail. Alternatively, this video by Jess Chan of Coder Coder is an excellent resource for beginners.
Following along with @SMasonGarrison's open source data science for psychologists course has helped me finally understand @github which has improved my work and my life so much 😭🎉
— Jen Traver (@jmtraver1) October 17, 2021
7.1 The Basics of GitHub and Git
7.1.1 What is Git?
Git is a distributed Version Control System (VCS), which means it is a useful tool for easily tracking changes to your code, collaborating, and sharing. With Git you can track the changes you make to your project so you always have a record of what you’ve worked on and can easily revert back to an older version if need be. It also makes working with others easier—groups of people can work together on the same project and merge their changes into one final source!
7.1.2 What is GitHub?
GitHub extends Git’s capabilities by providing a web-based interface for collaboration. It’s widely used for code development, allowing multiple people to work together on projects. GitHub hosts your repositories (project folders) and provides tools for managing changes, reviewing code, and collaborating with others.
7.2 Getting Started with GitHub
7.2.1 Create a GitHub Account
Sign up at github.com. Choose a thoughtful username as it represents you in the GitHub community. You will be able to upgrade to a paid level of service, apply discounts, join organizations, etc., in the future.
7.2.1.1 Username advice
You will be able to upgrade to a paid level of service, apply discounts, join organizations, etc. in the future, so don’t fret about any of that now. Except your username. You might want to give that some thought.
A few tips, which sadly tend to contradict each other:
- Incorporate your actual name! People like to know who they’re dealing with. Also makes your username easier for people to guess or remember.
- Reuse your username from other contexts, e.g., Twitter or Slack. But, of course, someone with no GitHub activity will probably be squatting on that.
- Pick a username you will be comfortable revealing to your future boss.
- Shorter is better than longer.
- Be as unique as possible in as few characters as possible. In some settings GitHub auto-completes or suggests usernames.
- Make it timeless. Don’t highlight your current university, employer, or place of residence, e.g. JennyFromTheBlock.
- Avoid words laden with special meaning in programming. In Jenny’s first inept efforts to script around the GitHub API, she assigned lots of issues to the guy with username
NA
because my vector of GitHub usernames contained missing values. A variant of Little Bobby Tables. - Avoid the use of upper vs. lower case to separate words. We highly recommend all lowercase. GitHub treats usernames in a case insensitive way, but using all lowercase is kinder to people doing downstream regular expression work with usernames, in various languages. A better strategy for word separation is to use a hyphen
-
or underscore_
.
You can change your username later, but better to get this right the first time.
7.2.2 Install Git and a Git client
Install Git: Essential for interacting with GitHub. Installation instructions are available for Windows, macOS, and Linux/Unix.
Install a Git client: GitHub offers a free Git(Hub) client, GitHub Desktop, for Windows and macOS. GitHub Desktop is aimed at beginners who want the most useful features of Git front and center. The flipside is that it may not support some of the more advanced workflows exposed by the clients above. At present, this client is what I, Mason, mostly use.
7.3 Half the battle
Getting all the necessary software installed, configured, and playing nicely together is honestly half the battle when first adopting Git. Brace yourself for some pain. The upside is that you can give yourself a pat on the back once you get through this. And you WILL get through this.
You will find far more resources for how to use Git than for installation and configuration. Why? The experts …
- Have been doing this for years. It’s simply not hard for them anymore.
- Probably use some flavor of Unix. They may secretly (or not so secretly) take pride in neither using nor knowing Windows.
- Get more satisfaction and reward for thinking and writing about Git concepts and workflows than Git installation.
In their defense, it’s hard to write installation instructions. Failures can be specific to an individual OS or even individual computer.
7.3.1 What is a Git client? Why would you want one?
“Git” is really just a collection of individual commands you execute in the shell. This interface is not appealing for everyone. Some may prefer to do Git operations via a client with a graphical interface.
Git and your Git client are not the same thing, just like R and RStudio are not the same thing. A Git client and an integrated development environment, such as RStudio, are not necessary to use Git or R, respectively. But they make the experience more pleasant because they reduce the amount of command line bullshittery and provide a richer visual representation of the current state.
RStudio offers a very basic Git client via its Git pane. I use this often for simple operations, but you probably want another, more powerful one as well.
- Install a Git client: GitHub offers a free Git(Hub) client, GitHub Desktop, for Windows and macOS. GitHub Desktop is aimed at beginners who want the most useful features of Git front and center. The flipside is that it may not support some of the more advanced workflows exposed by the clients above. At present, this client is what I, Mason, mostly use.