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

These slides are at slides.stevelosh.com if you want to follow along now or check them out later.

!SLIDE

We need to talk about version control.

!SLIDE

What kind of things are you working on right now?

!SLIDE

Maybe something like:

  • A website
  • Some blog posts
  • A thesis
  • A book
  • An iPhone app

!SLIDE

Version control can make your life easier.

!SLIDE

So what is version control?

!SLIDE

A version control system keeps track of versions of files on your computer.

!SLIDE

You've probably all seen some kind of version control.

!SLIDE images

Dropbox

Dropbox example

!SLIDE images

Writeboard

Writeboard example

!SLIDE images

Time Machine

Time Machine example

!SLIDE images

Wikipedia

Wikipedia example

!SLIDE

All of those sites keep track of versions of your files.

!SLIDE

You can go back in time to any version and see what the file looked like at that point.

!SLIDE

What if you don't want to put your files online?

 

What about files on your own computer?

!SLIDE

Wouldn't it be nice to be able to keep track of your important files without uploading them somewhere?

!SLIDE images

This is unacceptable.

Not Version Control, Not Even a Little Bit

!SLIDE

This is a version control system:

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 look cool 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

!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 revert --all or git reset --hard

!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

Let's take a closer look.

!SLIDE

You're working on a website (or a book, or anything else).

 

You want to "check in" your files 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 project.

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 project.

!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 remember this version of the project."

!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 project to how it looked when I last committed!"

!SLIDE images

The kitten will then restore your files.

Restore latest

!SLIDE

Of course, you could also say:

&nbsp;

"Kitten, restore my project to version 2!"

!SLIDE images

The kitten will then restore your files to how they 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

Questions?

!SLIDE

Credits

!SLIDE code

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

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.