Intro to Git

Obligitory XKCD

It's really pretty simple...

Git is a tool for snapshotting with some really powerful tools for navigating and combining those snapshots


Follow Instructions

Initial configuration

Some common configuration options here. At a bare minimum, make sure you set your name and email

$ git config --global "John Iacona"
$ git config --global


Repo exists on Github, you want it on your computer

$ git clone

Code exists on your computer, you want it on Github

$ git init
$ git remote add origin
$ git add .
$ git push -u origin master

File lifecycle

A file can exist in one of 4 states in git

  1. Untracked
  2. Modified
  3. Staged
  4. Committed
git status is your friend


Create a new file for your bio and add it to git

$ vim docs/people/
$ git add docs/people/


Add your bio and see what has changed

$ vim docs/people/
$ git diff


Once you are happy with your changes, add them to the staging area

$ git add docs/people/


Finally, make an official snapshot of all staged changes

$ git commit -m "Super useful commit message"

Aside about commit messages

other obligatory xkcd...

Commit messages should document what you have done for others and your future-self

Think about what you've done

$ git log
If you are using my .gitconfig file, the following aliases can be useful.

$ git lol
$ git lola

Push it (real good)


Another copy of a repo. origin is the most common

$ git push -u origin HEAD

So fetch

If the remote repo has progressed beyond yours, you have to fetch changes and merge them with yours

$ git fetch
$ git merge origin/master

fetch vs. pull

pull tries to fetch and merge in one step.

$ git pull