--for-hackathons A Fast Introduction to Version Control Whos done - - PowerPoint PPT Presentation

for hackathons
SMART_READER_LITE
LIVE PREVIEW

--for-hackathons A Fast Introduction to Version Control Whos done - - PowerPoint PPT Presentation

--for-hackathons A Fast Introduction to Version Control Whos done this before? http://thedailywtf.com/Comments/The_Best-est_Version_Control.aspx $$$ software does this! When projects get huge When projects get huge Today, youre going to


slide-1
SLIDE 1

A Fast Introduction to Version Control

  • -for-hackathons
slide-2
SLIDE 2

Who’s done this before?

http://thedailywtf.com/Comments/The_Best-est_Version_Control.aspx

slide-3
SLIDE 3

$$$ software does this!

slide-4
SLIDE 4

When projects get huge

slide-5
SLIDE 5

When projects get huge

slide-6
SLIDE 6

Today, you’re going to see a better way of doing things.

slide-7
SLIDE 7

Kevin Chen @kevinchen

slide-8
SLIDE 8

Kevin Chen @kevinchen

slide-9
SLIDE 9

Git organizes snapshots for you

slide-10
SLIDE 10

The Basics

slide-11
SLIDE 11

Download Git

OS X Install Xcode Windows Install Cygwin Linux Use your package manager

slide-12
SLIDE 12

git command options

slide-13
SLIDE 13

Set up Git

git config --global user.name "Kevin Chen" git config --global user.email "kevinchen2003@gmail.com" git config --core.editor "nano"

slide-14
SLIDE 14

Repository (“Repo”)

A folder where Git is tracking changes

slide-15
SLIDE 15

cd my_project git init

Make a new repository

slide-16
SLIDE 16

Commit

A snapshot of your repository

slide-17
SLIDE 17

Commit

You’re committing to the changes you made

slide-18
SLIDE 18

Steps to Commit

git status (Which files changed?) git diff (Which lines of code changed?) git add my_program.c (I want this file in my next commit) git add foo.c bar.c (Super fancy!) git commit (OK, save a snapshot of what I just added) git log (Show me the commit history)

slide-19
SLIDE 19

Commit messages should have
 a concise summary.

Put it in the first line. 70 characters or less.

slide-20
SLIDE 20

Commit messages should have 
 a detailed explanation.

Skip a line. Wrap your text at 70 characters.

slide-21
SLIDE 21

Fix a crash when taking pictures on Mondays

  • The function determine_photo_folder calculated the date index for Monday as
  • 1, causing the statistics-tracking code to access invalid memory. The app

will try to recover lost photos when users update to this version.

< 70 characters

slide-22
SLIDE 22

fuck this project, i hate programming

? ? ?

slide-23
SLIDE 23

Fix a nasty race condition when analyzing multiple images

  • fuck this project, i hate programming

slide-24
SLIDE 24

Demo: The Basics

slide-25
SLIDE 25

602925ce 9c5c3a97 f115369

slide-26
SLIDE 26

repository (“repo”) A folder where Git is tracking changes commit a snapshot

slide-27
SLIDE 27

Git as a safety net

slide-28
SLIDE 28

Reset

You messed something up and you want to go back.

slide-29
SLIDE 29

git checkout -- my_file.c

Revert my_file.c to the last commit

slide-30
SLIDE 30

git reset --hard 61874b3

Revert everything to the commit specified by 61874b3

slide-31
SLIDE 31

git reset --hard

Revert everything to the most recent commit

slide-32
SLIDE 32

What if you wanted that code, but not at that moment?

slide-33
SLIDE 33

Branching

Track separate versions of your code

slide-34
SLIDE 34

602925ce 9c5c3a97 f115369

slide-35
SLIDE 35

Making a branch

git branch (List the branches of the repo) git branch branch_name (Make a branch called branch_name) git checkout branch_name (Switch to branch_name) Now you can commit changes to that branch.

slide-36
SLIDE 36

602925ce 9c5c3a97 f115369

slide-37
SLIDE 37

602925ce 9c5c3a97 f115369 c5eb68a 9b41f5b b66e76b 64ba3bb

master my_branch

slide-38
SLIDE 38

Merging a branch

git checkout destination_br (Switch to the destination branch) git merge other_br (Merge other_br into this branch) git branch -D other_br (Delete other_br if you want)

slide-39
SLIDE 39

Demo: Git as a safety net

slide-40
SLIDE 40

Recap

slide-41
SLIDE 41

RECAP

Git helps you organize snapshots

  • f your projects.
slide-42
SLIDE 42

RECAP

These snapshots are called commits.

slide-43
SLIDE 43

RECAP

If you mess up, you can always go back as long as there’s been a commit.

slide-44
SLIDE 44

RECAP

Branches let you try out new ideas without losing access to the version that works.

slide-45
SLIDE 45

Additional Resources

gitimmersion.com (interactive tutorial) git-scm.com (has a ridiculously detailed book on Git) think-like-a-git.net (more advanced git)

slide-46
SLIDE 46

A Fast Introduction to Version Control

  • -for-hackathons
slide-47
SLIDE 47

Twitter @kevinchen Website kevinchen.co I’m good at C/C++, Java, Git, servers, electronics, Photoshop I’m OK with Web development, Ruby, Rails