Git & GitHub
Getting Started Workshop
originally by Gwen Lofman
modified by Greg Willard
Follow along with the slides at
Shortened link: goo.gl/53L48V
- up and running with
gitas a standalone user
gitas a participant
command subcommand -o --option
Navigating the file system
cd- change directory
ls- list files & directories
mkdir- make directory
This is an example of bad version control.
This is an example of good version control.
Up and Running
Linux usually comes with
git help or documentation at git-scm.com/doc
You can get help for individual commands with
git help [command]
Git also has an extensive manual with
git needs to know who you are.
git need my name?
Git associates every change with a name and email so you can tell who changed what.
git as a standalone developer
A mental model for staging
You don't want to make a commitment until everything is ready.
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 folder holds the internals of git.
git status shows the status of your repository.
git status gives suggestions about what to do next.
git diff shows untracked changes inside your files
git add stages changes
Stage relevant changes together
git add -p lets you add parts of a file.
git reset HEAD -- unstages changes
git commit adds a change to the history
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 README.md 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 revert undoes changes
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
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
To bring changes back from your stash:
git stash apply
How do I get changes from one branch to another?
This is typically what happens with a git merge.
A mental model for merging
Sometimes git can fast-forward
Now to the GitHub part!
Let's get interactive!
Sign up at GitHub.com/join