this is what a programmer looks like - https://octodex.github.com/robotocat

Whew! It’s been a busy couple of weeks at work, and in the midst of a big product release, I was was slated to give a talk on git & GitHub through Girl Develop It Philly. I was really stoked to give this lecture because I consider git to be an essential development tool: I use it for work, I use it for personal projects, I feel nervous if important code only exists locally. Luckily, I had some great TAs for the class. Selah Lynch, Sarah Johnson, and Jana Beck gave me lots of insightful ideas for our slide deck and lab.

Over all, I think the class went well. As always, it’s a little tricky to gauge how comfortable attendees will be with the command line, but the class seemed to roll with things nicely. Participants were asking good questions throughout the lecture, then they made it through the lab exercise, and most finished the day by playing with the githug gem. As a side benefit, we used github.io for our lab instructions — sweet, I learned something new too :)

Since our class was heavily focused on using git with GitHub from the command line, we made a paper cheat sheet for use during the lab. I use the cheat sheet commands below all the time and, dear reader, you will likely need them too if you are new to git. So, without further ado, here are what I consider to be essential git commands …

The Git Cheat Sheet

Clone an Existing Repo

git clone <repo link from github>	//get code from the remote repo to your local machine

The Basic Idiom

git pull	//let me see what others have done resolve merge conflicts early
git add filename	//let me bundle some work together
git commit -m “my comment”	//let me make a note about that bundle
git push	//send it up to the remote repo

Log & Status Commands

git status	//show me what’s happening right now
git log	 //show me the timeline to exit the log view, type q
git log --pretty=oneline	//show me a simplified log to exit the log view, type q

Stash Commands

git stash save “note about what I am saving”	//My current work is not ready to be committed but I want to git pull and see what’s going on with the remote repo
git stash pop	//apply the last stashed change
git stash list	//show me all stashed changes to exit the stash view, type q
git diff filename	//show me what’s changed in this file since last commit to exit the diff view, type q

Manipulating the Timeline Idiom

git log	//pick a SHA/commit id to roll back to
git reset //SHA/Commit ID from log	roll back to that point in the log locally
git pull	//reset local repo to match remote repo

Branch Commands

git branch	//what branch am I in?
git branch -a	//see local and remote branches
git checkout --track origin/branch name	//get a remote branch onto your local machine
git branch branch name	//make a new local branch
git push -u origin branch name	//create branch on remote
git checkout branch name	//switch between branches

Merge with Master Idiom

git checkout master	//go to master branch
git merge branch name	//add changes form branch name to master

Resolving Merge Conflicts

git mergetool	//opens a graphical interface for selecting how to resolve merge conflicts

The Slide Deck

Want to see the deck in full screen with clickable links? See the original slideshow. Looking for a shortcut to the lab resources? Here it is. If you are looking for the cheat sheets from class, checkout the git_resources directory in the lab repo.

More Git & GitHub Resources