Source

slides / use-version-control / use-version-control.md

!SLIDE

Using Version Control Will Make You Happy

!SLIDE

Hi, I'm Steve Losh

!SLIDE

Senior Software Engineer at

Dumbwaiter Design

!SLIDE

We Need to Talk

!SLIDE

You've probably heard about version control

!SLIDE images

This is not version control

Not Version Control, Not Even a Little Bit

!SLIDE

This is version control:

Mercurial

 

And so is this:

Git

!SLIDE

Why should you care?

!SLIDE images

Let's look at an example. Here's my website:

stevelosh.com

!SLIDE

Wouldn't it be sweet if I staggered the navigation?

!SLIDE

… code for 30 minutes …

!SLIDE images

Hmm, I'm not sure about this

stevelosh.com staggered

Wait a second…

!SLIDE images

Oh god what was I thinking?

stevelosh.com staggered blog

Kill it with fire!

!SLIDE

How do you go back to the good version?

!SLIDE

Without version control:

  1. Pour a glass of whiskey
  2. Code for 30 more minutes

!SLIDE

With version control:

  1. hg update --clean

!SLIDE

Version control just saved you:

  1. 30 minutes
  2. A glass of whiskey

!SLIDE

Whiskey is expensive, so let's all use version control, okay?

!SLIDE

So what is version control?

!SLIDE

It's a way to keep track of versions of things you work on

!SLIDE

Sorry, that was a useless answer

!SLIDE

You're working on a website

 

You want to "check in" your code as you work

!SLIDE

This gives you a record of your changes

 

It also lets you blow away bad ideas easily

!SLIDE

So how does it work?

!SLIDE images

You've got a folder containing your website

Normal website folder

!SLIDE images

Now add another folder inside it, containing a magic kitten

Version controlled website folder

!SLIDE

The kitten will keep track of each version of your website

!SLIDE

How does it really work?

!SLIDE

Every time you "commit" the current state of your website is recorded by the kitten

 

"Commit" means "tell the kitten to record this version of the site"

!SLIDE images

After committing five times, your folder looks like this

Reality

!SLIDE

Suppose you make some changes and decide you don't really like them

!SLIDE

Now you can say:

 

"Kitten, I was foolish! <br/> Please restore my code to how it looked when I last committed!"

!SLIDE images

The kitten will then restore your code

Restore latest

!SLIDE

Of course, you could also say:

&nbsp;

"Kitten, restore my code to version 2!"

!SLIDE images

The kitten will then restore your code to how it looked in version 2

Restore v2

!SLIDE

You can use version control to restore any committed version.

!SLIDE

Learn More

&nbsp;

Mercurial

&nbsp;

Git

!SLIDE

Credits

!SLIDE code

@@@ python def foo :bar end @@@

!SLIDE

Google is here

!SLIDE

Questions?

Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.