quick intro to git

74
let’s roll

Upload: hasan-veldstra

Post on 15-Jan-2015

2.390 views

Category:

Technology


1 download

DESCRIPTION

Slides+notes for a talk on Git I did at Techmeetup Edinburgh back in January '09.

TRANSCRIPT

Page 1: Quick intro to Git

let’s roll

Page 2: Quick intro to Git

GIT

Page 3: Quick intro to Git

Hasan Veldstra<[email protected]>

hypernumbers

Really Quick Intro To Git

quick poll: Git users, SVN users.

Page 4: Quick intro to Git

source control system

the logo:

an artistic impression:

like CVS or SVN, only much better. fundamental difference – distributed.

Page 5: Quick intro to Git

SVNCVS

Page 6: Quick intro to Git

SVNCVS

GIT ⋙ {

Page 7: Quick intro to Git

roadmap, disclaimers &c

why it’s cool, how it works, how to get started right now. basic stuff – if you like what you see, there’s lots of detailed documentation elsewhere.

i am not an expert, just sharing bits i’ve learned.

Page 8: Quick intro to Git

2005, to manage Linux kernel, spread fast.

Page 9: Quick intro to Git
Page 10: Quick intro to Git

Linux kernel

Page 11: Quick intro to Git

X11

Page 12: Quick intro to Git

Perl

Page 13: Quick intro to Git

Android

Page 14: Quick intro to Git

Fedora

Page 15: Quick intro to Git

OLPC

Page 16: Quick intro to Git

Ruby On Rails

Page 17: Quick intro to Git

WINE

Page 18: Quick intro to Git

VLC

Page 19: Quick intro to Git

Git itself

Page 20: Quick intro to Git

why Git?

Page 21: Quick intro to Git

• makes stuff cheap

why Git?

= streamlines things & encourages good practices

Page 22: Quick intro to Git

• makes stuff cheap• any workflow

why Git?

gets out of your way, doesn’t dictate the way you should work. use it like SVN or use it like the Linux devs.

Page 23: Quick intro to Git

• makes stuff cheap

• fast• any workflow

why Git?

by design & implementation (no network, speed as one of the goals, written in C by great C hackers)

Page 24: Quick intro to Git

from http://whygitisbetterthanx.com by Scott Chacon of GitHub

SVN is even slower than Bazaar

Page 25: Quick intro to Git

• makes stuff cheap

• fast• small

• any workflow

why Git?

as small or smaller than an equivalent SVN repo.

Page 26: Quick intro to Git

• makes stuff cheap

• fast• small

• any workflow

• easy to learn

why Git?

Git has acquired a reputation for being somewhat difficult to get started with and understand but that’s lies.

Page 27: Quick intro to Git

$ cd (project directory)$ git init$ (create some files)$ git add .$ git commit -m 'start the project'

Page 28: Quick intro to Git

distributed

Page 29: Quick intro to Git

distributed=

no central repository

Page 30: Quick intro to Git

distributed=

no central repository

(superset of SVN &c)

Page 31: Quick intro to Git

centralized (SVN):

repository

Page 32: Quick intro to Git

centralized (SVN):

repository

!

Page 33: Quick intro to Git

centralized (SVN):

repository

!! devs “check out” the code to create a

“working copy”

Page 34: Quick intro to Git

centralized (SVN):

repository

check in!

!

Page 35: Quick intro to Git

centralized (SVN):

repository

check in!check out

!

Page 36: Quick intro to Git

centralized (SVN):

repository

check in!check out

! make changes

Page 37: Quick intro to Git

centralized (SVN):

repository

check in!check out

! make changes

check in back to repo

Page 38: Quick intro to Git

centralized (SVN):

repository

check in

update

!check out! make changes

check in back to repo

Page 39: Quick intro to Git

centralized (SVN):repository

one-to-many relationship

Page 40: Quick intro to Git

centralized (SVN):repository

- - -

- -

- - - working copy #1

Page 41: Quick intro to Git

centralized (SVN):repository

- - -

- -

- - - working copy #2- - -

- -

- - - working copy #1

Page 42: Quick intro to Git

centralized (SVN):repository

- - -

- -

- - - working copy #3

- - -

- -

- - - working copy #2- - -

- -

- - - working copy #1

Page 43: Quick intro to Git

centralized (SVN):

• working copies are inferior

Page 44: Quick intro to Git

centralized (SVN):

• working copies are inferior

• & can’t talk to each other

Page 45: Quick intro to Git

centralized (SVN):

• working copies are inferior

• & can’t talk to each other

• you gotta be online

Page 46: Quick intro to Git

centralized (SVN):

• working copies are inferior

• & can’t talk to each other

• you gotta be online

• single point of failure

Page 47: Quick intro to Git

distributed (Git):

Page 48: Quick intro to Git

distributed (Git):

checkout

Page 49: Quick intro to Git

distributed (Git):

checkout

clonewe don’t check out, we cloneclone = full history, can do anything original can

Page 50: Quick intro to Git

distributed (Git):

“canonical” repository

"canonical" because it's a social convention, not a technical requirement

Page 51: Quick intro to Git

distributed (Git):

!

local repository #1

“canonical” repository

Page 52: Quick intro to Git

awesome #1

Page 53: Quick intro to Git

awesome #1

local commitsno network => FASTFAST => less “friction”less “friction” => encourages you to commit more often

no network => work offlinebig deal actually, i work in Starbucks a lot, actualy the reason i started using Git in the first place. also nice to be productive on trains, planes &c.

it also allows private work, so you can use your revision control system even for early drafts you don't want to publish

Page 54: Quick intro to Git

awesome #1

local commits#1 say you’re working on a feature, & you do the work

in several stages, over a couple of days maybe

you know, you write the first messy and inefficient version first, and then you refactor it, test it &c &c.

Page 55: Quick intro to Git

awesome #1

local commits#1 #2

Page 56: Quick intro to Git

awesome #1

local commits#1 #2 #3

with SVN you either commit all intermediate steps to the central repo, which clutters up history...

... or you don’t, in which case you’re left on your own and there is no one there to save your butt WHEN you screw up: you can’t roll back to an earlier state, you can only restore clean from the server, losing work.

this of course sucks big time.

Page 57: Quick intro to Git

awesome #1

local commits(& revision before pushing)

Page 58: Quick intro to Git

distributed (Git):

!

local repository #1

“canonical” repository

Page 59: Quick intro to Git

distributed (Git):

!

!

local repository #1

local repository #2

“canonical” repository

Page 60: Quick intro to Git

distributed (Git):

“canonical” repository

!

!

local repository #1

local repository #2

Page 61: Quick intro to Git

distributed (Git):

“canonical” repository

!

!

local repository #1

local repository #2= awesome

clones are full-fledged repositories => exchange patches and merge between them without touching the main repo.

several people can work together on something new amongst themselves, and then push to main when done.

Page 62: Quick intro to Git

staging area“canonical” repository

local repository

- - -

- -

- - - working copy

- -

-

- - -

staging area

like a shelf on which to put things that’ll make up the next commit. incremental building of. “chunk commits” = awesome. “tangled working copy” problem gone.

object database, trees & blobs that represent the repo (file contents,

stuff on your disk tracked by the repo

Page 63: Quick intro to Git

as many as you wantindependent of each otherprivateFAST operations (create, check out, merge, delete)

* for new ideas* for bugfixes/features* master for production, one for testing, several for day-to-day work

changes the way you workcan manage to do some of this with other systems, but is PITA.

branching

Page 64: Quick intro to Git

workflows

Page 65: Quick intro to Git

centralizedbasically like SVN but nicer

Page 66: Quick intro to Git

integration manager

blessed repo, integration manager, many devs.“open-source model”.

Page 67: Quick intro to Git

dictator&

lieutenantsfor massive projects, like Linux Kernel

Page 68: Quick intro to Git

infiltrationa howto

start using Git tomorrow without anyone suspecting a thing.

Page 69: Quick intro to Git

git-svn

Page 70: Quick intro to Git

$ git svn clone (URL)$ git branch bugfix-branch$ git checkout bugfix-branch(make a bunch of changes)$ git commit -m “fixed this bug”$ git rebase -i git-svn$ git checkout master$ git svn rebase$ git rebase bugfix-branch$ git svn dcommit

...all it takes

Page 71: Quick intro to Git

Tools• egit for Eclipse• magit for Emacs• plugins for NetBeans & Visual Studio in the works• so is a TortoiseSvn equivalent

• also Gitx on OSX, gitk on Linux• gitweb to serve repos over HTTP

Page 72: Quick intro to Git

Nothing is perfect

SVN handles binary files better

SVN allows partial check outs

Page 73: Quick intro to Git

git-scm.com#git on Freenode

github.com

MOAR:

Trac + Sourceforge + Facebook :]

Page 74: Quick intro to Git

Questions