Git & GitHub

Getting Started Workshop

originally by Gwen Lofman

modified by Greg Willard

Follow along with the slides at

Shortened link:


  • up and running with git
  • git as a standalone user
  • git as a participant

Command Syntax

command subcommand -o --option

Navigating the file system

  • cd - change directory
  • ls - list files & directories
  • mkdir - make directory

What is git?

bad version control

This is an example of bad version control.

good version control

This is an example of good version control.

Up and Running


Linux usually comes with git installed



`sudo apt-get install git`

Getting Help

git help or documentation at

git help

You can get help for individual commands with
git help [command]

git help status

Git also has an extensive manual with
man git

man git


git needs to know who you are.

git config --global [name] && git config --global [email]

Why does git need my name?

Git associates every change with a name and email so you can tell who changed what.

Using git as a standalone developer

A mental model for staging

You don't want to make a commitment until everything is ready.

The git commit workflow

  • Each commit is a patch
  • You must prepare a commit before finalizing it
  • Each commit is a unit of work, put related changes together.

A git repository is a directory on your computer.

git init

Your .git folder holds the internals of git.

git status shows the status of your repository.

git status

git status gives suggestions about what to do next.

git status suggestions

git diff shows untracked changes inside your files

git diff

git add stages changes

git add

Stage relevant changes together

git add -p lets you add parts of a file.

git add -p

git reset HEAD -- unstages changes

git reset HEAD --

git commit adds a change to the history

git commit

Apply all of your staged changes. esc :x leaves the editor.

git commit takes a message that describes the patch. Writing a good message is key:

  • Write in present imperative, for example:
    • Add to describe project
    • Implement improved error handling, fixes #13
  • Think of commit messages like emails
  • Describe not just what, but why

git log shows your past changes.

git log

git revert undoes changes

git revert

Using git as a participant

git is distrubuted version control.

Different participants in a project can share changes between each-other

git branch lets you work on changes in isolation

git branch

One feature to rule them all!

A mental model for branches

Like a branch on a family tree.

NOTE: checking out a branch changes the files in your repository.

git stash let's you save changes for later

git stash

To bring changes back from your stash: git stash apply

git stash apply

Manipulating Branches

How do I get changes from one branch to another?

  • git merge
  • git rebase
git merge meme

This is typically what happens with a git merge.

A mental model for merging

Integrate changes

Sometimes git can fast-forward

Now to the GitHub part!

Let's get interactive!

Sign up at