CMU 15-539: Computer Science Pedagogy, Fall 2017
Notes: Git Overview

539 Git Overview

About this Doc




Introduction + Motivation

Git is a tool everyone in 539 will need to know this semester.

From term projects and malloc, most of you have probably used git to go back to old versions of your own code. This document focuses on how to use git as a collaborative tool. In 539 you are building a product, so we you use version control the way it is used in industry, not the way you use it for a personal project.

Git will be the medium through which we will store, share, review, and export code. If you want to contribute to 539 code, you need to know git.

Git Vocabulary

Git - Git is a tool that lets us take snapshots of our codebase, called versions. Git also lets us switch between new and old versions, combine versions and share our versions with other people.

GitHub - GitHub is a website that hosts GitHub repositories, but is distinct from plain old “git.” GitHub puts our git repository in the cloud, so it is easier to share code with one another. We will also use GitHub’s project management tools, like its issue tracker and code review system. Neither is part of standard git.

Repository - Git stores the history of each project in a repository. We will probably have at least one repository for each team.

Commit - When you want to save a copy of your code, either to go back to in the future, or to share it with someone else, you bundle up your changes in a commit. You can use the word commit as a verb:

Hey! That little change fixed the bug, I’ll commit my code now so I can come back to it if <crazy change> doesn’t work out.

Sometimes, commit is used as a noun, referring to a specific version of the code:

        Can we revert master back to the previous commit? The last change broke it.

Branch - A branch is a specific sequence of commits. Usually, we have multiple branches in the same repository. Contributors can commit code to one branch without interfering with the others, which is what makes it so easy to collaborate on different features in the same repository.

Remote - When you see remote, think “on GitHub.” A local branch or repository is one that you created on your computer, if you don’t push it to remote, your local code will never appear on gitHub.

Push/Pull - Pulling is taking code from a remote branch, and putting it into your local branch. Pushing is taking the code that you have on your computer, and writing it to a remote branch.

Merge - Merging is the process of reconciling changes that happened in one branch or commit with changes that happened in another. When two people edit code in the same repository, they have to merge it together.

Merge Conflict - If you try to merge two commits that edit the same lines of code, there is a “conflict” that you as the programmer must resolve. Merge conflicts are the ugliest part of git, when in doubt, ask for help!

Pull Request - A pull request is a request to merge code you committed on one branch into another. It is also the time when we will do code reviews. Pull requests happen on GitHub.

Visual Workflows

To see visual representations of workflows, see this PDF.

Best Practices

Be altruistic when using git for collaboration. If you put it an extra few seconds of work on your end, you will save your reviewers and collaborators oodles of time.


What should I download?

If you have a mac or linux machine, and feel at home in your terminal, you’re in luck! Git is already installed. See the “Learning Git Commands” section to get started.

If you use Windows, are uncomfortable in a terminal, or want to avoid learning a fairly complex terminal command, you should download a git GUI. GitHub provides simple GUIs, and GitKraken is a more advanced client that is free for non-commercial use.



Best Practices / Workflow