Important Non-Basketball Post: Setting Up GitHub

Dan Watson
Hardwood Convergence
6 min readJul 20, 2019
github octocat
source: https://github.com/logos

I know we want to jump into analyzing basketball data, but first let’s make sure we have our framework set up so we can efficiently save, track, and share our work. For that, we’ll use GitHub.

What is Git and GitHub?

Let’s start with Git. According to it’s website, Git is a

free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency.

Simply, Git is just a tool that helps you keep track of code. Think about working on a group project: You write a document and save it as project.doc. You then send the file to your teammate who makes changes and saves it as project_mike_edits.doc. At the same time, you’ve made changes and you have project_v2.doc on your local machine. Now you and Mike get together to create a finalize the document and things aren’t lining up. You each made non-linear changes and now you have to rework the paper to make it cohesive.

Git helps prevent this. It takes snapshots of the tracked files over time, allowing multiple users can work on the same code at the same time, revert to previous edits, and efficiently merge changes into the final code.

GitHub just adds a Hub to Git- meaning that it’s a centralized location to store and share our files using Git. Now you can work on projects with people around the globe and not deal with trying to compare code line by line. Sweet.

Do I Really Need to Know This?

Honestly, yes. All the code for this site will be on GitHub. If you just want to follow along with tutorials, you probably just need to know how to setup Git and download a repository. If you plan on creating a portfolio, sharing code online, or working on projects with other people, you might as well learn the basics now and save yourself from frustration later.

Using Git and GitHub

There are a ton of great resources available to teach you the basics of using Git and GitHub, so we won’t spend time reinventing the wheel. The easiest way is probably to first work through this tutorial at CodeAcademy. If that’s too much work (it isn’t), just check out this video:

TraversyMedia: Git Crash Course

Setting Up A GitHub Account

I already have Git installed on my computer and I’m sure you do too if you watched the video above. If you refused to do the walk-thru or watch the video, just download Git from here, install it, and following along.

  1. Go to GitHub.com, enter your information, and click Sign up for GitHub.
GitHub sign upGitHub sign up
GitHub sign up

2. After you verify your account, select the free tier account.

Select account type
Select account type

3. After you answer some final questions and verify your account, you’ll end up on the GitHub homepage. From here, if you wish to create your own repository, click Start a project.

Starting a new GitHub project
Start a project

4. Now we’ll just name our repository, give it a quick description, and initialize it with a readme file. If you do not initialize the repository with a readme, you can still clone it to your local computer, but the repository won’t contain any branches. This isn’t a huge issue, but it’s way easier just to include the readme. Plus, it’s good practice to include a readme in your repositories to describe your project and how to use it.

Create a new repository
Set up the repository

5. You’re now redirected to your repository and can see that the readme is displaying the description of your project. Let’s get this on our local machine by clicking on the Clone or download button and then copying the web address of our repository.

Copy the repository link
Copy the repository link

6. Open your Terminal on a Mac and navigate to the location where you would like to clone this repository. I’m going to put it on my desktop to make it easy to find. Next, type “git clone <repository web address>” (don’t include the angle brackets) and hit enter. You’ll see git downloading the repository and the folder will show on your computer.

Cloning the repository
Cloning the repository

7. Now, let’s add a file to our local folder and then sync it with our online repository. I’m going to place this picture of Celtic’s legend Brian Scalabrine, aka The White Mamba, into the medium_tutorials folder. Back in our terminal, we will navigate to our medium_tutorials folder and type git status to see how our local folder compares to the repository.

Viewing our git status
Viewing our git status

8. We see that we have an untracked file: White_mamba.png. Git shows us that we can use “git add <file>” to include it into our commit. If we don’t want to add each file individually, we can just type git add * and hit enter. Then type git status and hit enter again to see what changed.

Add our new file to git
Add our new file to git

9. The White_mamba.png file is now added to the git repository, but if you refresh your GitHub site, the file isn’t included. Why? We haven’t committed the file yet and synced it to GitHub! First we need to commit the file. We can type git commit -m and then write a quick comment for our commit. I’ll use git commit -m “first commit”. Make sure you put the quotation marks around your comment or you’ll also get an error like I did!

Adding our new file to our commit
Adding our new file to our commit

10. If you re-enter the git status command now, you’ll see that a message saying that “Your branch is ahead of ‘origin/master’ by 1 commit. Let’s sync the branches by pushing our local branch to the main repository with git push. You’ll see the files being uploaded to your GitHub repository and if you go to your GitHub repository, you’ll see the new file! Success!

Pushing our file to GitHub

Wrapping Up

Ok, we learned how to set up Git, start a GitHub repository, make local changes to the repository, and how to sync those changes with GitHub. Pretty painless and definitely powerful!

Next we’ll learn how to set up a virtual environment, install some python packages, and start scraping basketball data! Thanks for reading along- if you learned anything new on this post, please give a clap or two below!

Thanks!

--

--

Dan Watson
Hardwood Convergence

Data nerd, basketball fanatic, and ice cream connoisseur. Health care analytics by day, basketball analytics by night. https://www.linkedin.com/in/danielkwatson