quick intro to git

Post on 15-Jan-2015

2.390 Views

Category:

Technology

1 Downloads

Preview:

Click to see full reader

DESCRIPTION

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

TRANSCRIPT

let’s roll

GIT

Hasan Veldstra<hasan@hypernumbers.com>

hypernumbers

Really Quick Intro To Git

quick poll: Git users, SVN users.

source control system

the logo:

an artistic impression:

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

SVNCVS

SVNCVS

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.

2005, to manage Linux kernel, spread fast.

Linux kernel

X11

Perl

Android

Fedora

OLPC

Ruby On Rails

WINE

VLC

Git itself

why Git?

• makes stuff cheap

why Git?

= streamlines things & encourages good practices

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

• 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)

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

SVN is even slower than Bazaar

• makes stuff cheap

• fast• small

• any workflow

why Git?

as small or smaller than an equivalent SVN repo.

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

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

distributed

distributed=

no central repository

distributed=

no central repository

(superset of SVN &c)

centralized (SVN):

repository

centralized (SVN):

repository

!

centralized (SVN):

repository

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

“working copy”

centralized (SVN):

repository

check in!

!

centralized (SVN):

repository

check in!check out

!

centralized (SVN):

repository

check in!check out

! make changes

centralized (SVN):

repository

check in!check out

! make changes

check in back to repo

centralized (SVN):

repository

check in

update

!check out! make changes

check in back to repo

centralized (SVN):repository

one-to-many relationship

centralized (SVN):repository

- - -

- -

- - - working copy #1

centralized (SVN):repository

- - -

- -

- - - working copy #2- - -

- -

- - - working copy #1

centralized (SVN):repository

- - -

- -

- - - working copy #3

- - -

- -

- - - working copy #2- - -

- -

- - - working copy #1

centralized (SVN):

• working copies are inferior

centralized (SVN):

• working copies are inferior

• & can’t talk to each other

centralized (SVN):

• working copies are inferior

• & can’t talk to each other

• you gotta be online

centralized (SVN):

• working copies are inferior

• & can’t talk to each other

• you gotta be online

• single point of failure

distributed (Git):

distributed (Git):

checkout

distributed (Git):

checkout

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

distributed (Git):

“canonical” repository

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

distributed (Git):

!

local repository #1

“canonical” repository

awesome #1

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

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.

awesome #1

local commits#1 #2

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.

awesome #1

local commits(& revision before pushing)

distributed (Git):

!

local repository #1

“canonical” repository

distributed (Git):

!

!

local repository #1

local repository #2

“canonical” repository

distributed (Git):

“canonical” repository

!

!

local repository #1

local repository #2

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.

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

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

workflows

centralizedbasically like SVN but nicer

integration manager

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

dictator&

lieutenantsfor massive projects, like Linux Kernel

infiltrationa howto

start using Git tomorrow without anyone suspecting a thing.

git-svn

$ 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

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

Nothing is perfect

SVN handles binary files better

SVN allows partial check outs

git-scm.com#git on Freenode

github.com

MOAR:

Trac + Sourceforge + Facebook :]

Questions

top related