quick intro to git
DESCRIPTION
Slides+notes for a talk on Git I did at Techmeetup Edinburgh back in January '09.TRANSCRIPT
![Page 1: Quick intro to Git](https://reader037.vdocuments.us/reader037/viewer/2022102705/54b790a14a7959d7418b4660/html5/thumbnails/1.jpg)
let’s roll
![Page 2: Quick intro to Git](https://reader037.vdocuments.us/reader037/viewer/2022102705/54b790a14a7959d7418b4660/html5/thumbnails/2.jpg)
GIT
![Page 3: Quick intro to Git](https://reader037.vdocuments.us/reader037/viewer/2022102705/54b790a14a7959d7418b4660/html5/thumbnails/3.jpg)
Hasan Veldstra<[email protected]>
hypernumbers
Really Quick Intro To Git
quick poll: Git users, SVN users.
![Page 4: Quick intro to Git](https://reader037.vdocuments.us/reader037/viewer/2022102705/54b790a14a7959d7418b4660/html5/thumbnails/4.jpg)
source control system
the logo:
an artistic impression:
like CVS or SVN, only much better. fundamental difference – distributed.
![Page 5: Quick intro to Git](https://reader037.vdocuments.us/reader037/viewer/2022102705/54b790a14a7959d7418b4660/html5/thumbnails/5.jpg)
SVNCVS
![Page 6: Quick intro to Git](https://reader037.vdocuments.us/reader037/viewer/2022102705/54b790a14a7959d7418b4660/html5/thumbnails/6.jpg)
SVNCVS
GIT ⋙ {
![Page 7: Quick intro to Git](https://reader037.vdocuments.us/reader037/viewer/2022102705/54b790a14a7959d7418b4660/html5/thumbnails/7.jpg)
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](https://reader037.vdocuments.us/reader037/viewer/2022102705/54b790a14a7959d7418b4660/html5/thumbnails/8.jpg)
2005, to manage Linux kernel, spread fast.
![Page 9: Quick intro to Git](https://reader037.vdocuments.us/reader037/viewer/2022102705/54b790a14a7959d7418b4660/html5/thumbnails/9.jpg)
![Page 10: Quick intro to Git](https://reader037.vdocuments.us/reader037/viewer/2022102705/54b790a14a7959d7418b4660/html5/thumbnails/10.jpg)
Linux kernel
![Page 11: Quick intro to Git](https://reader037.vdocuments.us/reader037/viewer/2022102705/54b790a14a7959d7418b4660/html5/thumbnails/11.jpg)
X11
![Page 12: Quick intro to Git](https://reader037.vdocuments.us/reader037/viewer/2022102705/54b790a14a7959d7418b4660/html5/thumbnails/12.jpg)
Perl
![Page 13: Quick intro to Git](https://reader037.vdocuments.us/reader037/viewer/2022102705/54b790a14a7959d7418b4660/html5/thumbnails/13.jpg)
Android
![Page 14: Quick intro to Git](https://reader037.vdocuments.us/reader037/viewer/2022102705/54b790a14a7959d7418b4660/html5/thumbnails/14.jpg)
Fedora
![Page 15: Quick intro to Git](https://reader037.vdocuments.us/reader037/viewer/2022102705/54b790a14a7959d7418b4660/html5/thumbnails/15.jpg)
OLPC
![Page 16: Quick intro to Git](https://reader037.vdocuments.us/reader037/viewer/2022102705/54b790a14a7959d7418b4660/html5/thumbnails/16.jpg)
Ruby On Rails
![Page 17: Quick intro to Git](https://reader037.vdocuments.us/reader037/viewer/2022102705/54b790a14a7959d7418b4660/html5/thumbnails/17.jpg)
WINE
![Page 18: Quick intro to Git](https://reader037.vdocuments.us/reader037/viewer/2022102705/54b790a14a7959d7418b4660/html5/thumbnails/18.jpg)
VLC
![Page 19: Quick intro to Git](https://reader037.vdocuments.us/reader037/viewer/2022102705/54b790a14a7959d7418b4660/html5/thumbnails/19.jpg)
Git itself
![Page 20: Quick intro to Git](https://reader037.vdocuments.us/reader037/viewer/2022102705/54b790a14a7959d7418b4660/html5/thumbnails/20.jpg)
why Git?
![Page 21: Quick intro to Git](https://reader037.vdocuments.us/reader037/viewer/2022102705/54b790a14a7959d7418b4660/html5/thumbnails/21.jpg)
• makes stuff cheap
why Git?
= streamlines things & encourages good practices
![Page 22: Quick intro to Git](https://reader037.vdocuments.us/reader037/viewer/2022102705/54b790a14a7959d7418b4660/html5/thumbnails/22.jpg)
• 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](https://reader037.vdocuments.us/reader037/viewer/2022102705/54b790a14a7959d7418b4660/html5/thumbnails/23.jpg)
• 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](https://reader037.vdocuments.us/reader037/viewer/2022102705/54b790a14a7959d7418b4660/html5/thumbnails/24.jpg)
from http://whygitisbetterthanx.com by Scott Chacon of GitHub
SVN is even slower than Bazaar
![Page 25: Quick intro to Git](https://reader037.vdocuments.us/reader037/viewer/2022102705/54b790a14a7959d7418b4660/html5/thumbnails/25.jpg)
• makes stuff cheap
• fast• small
• any workflow
why Git?
as small or smaller than an equivalent SVN repo.
![Page 26: Quick intro to Git](https://reader037.vdocuments.us/reader037/viewer/2022102705/54b790a14a7959d7418b4660/html5/thumbnails/26.jpg)
• 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](https://reader037.vdocuments.us/reader037/viewer/2022102705/54b790a14a7959d7418b4660/html5/thumbnails/27.jpg)
$ cd (project directory)$ git init$ (create some files)$ git add .$ git commit -m 'start the project'
![Page 28: Quick intro to Git](https://reader037.vdocuments.us/reader037/viewer/2022102705/54b790a14a7959d7418b4660/html5/thumbnails/28.jpg)
distributed
![Page 29: Quick intro to Git](https://reader037.vdocuments.us/reader037/viewer/2022102705/54b790a14a7959d7418b4660/html5/thumbnails/29.jpg)
distributed=
no central repository
![Page 30: Quick intro to Git](https://reader037.vdocuments.us/reader037/viewer/2022102705/54b790a14a7959d7418b4660/html5/thumbnails/30.jpg)
distributed=
no central repository
(superset of SVN &c)
![Page 31: Quick intro to Git](https://reader037.vdocuments.us/reader037/viewer/2022102705/54b790a14a7959d7418b4660/html5/thumbnails/31.jpg)
centralized (SVN):
repository
![Page 32: Quick intro to Git](https://reader037.vdocuments.us/reader037/viewer/2022102705/54b790a14a7959d7418b4660/html5/thumbnails/32.jpg)
centralized (SVN):
repository
!
![Page 33: Quick intro to Git](https://reader037.vdocuments.us/reader037/viewer/2022102705/54b790a14a7959d7418b4660/html5/thumbnails/33.jpg)
centralized (SVN):
repository
!! devs “check out” the code to create a
“working copy”
![Page 34: Quick intro to Git](https://reader037.vdocuments.us/reader037/viewer/2022102705/54b790a14a7959d7418b4660/html5/thumbnails/34.jpg)
centralized (SVN):
repository
check in!
!
![Page 35: Quick intro to Git](https://reader037.vdocuments.us/reader037/viewer/2022102705/54b790a14a7959d7418b4660/html5/thumbnails/35.jpg)
centralized (SVN):
repository
check in!check out
!
![Page 36: Quick intro to Git](https://reader037.vdocuments.us/reader037/viewer/2022102705/54b790a14a7959d7418b4660/html5/thumbnails/36.jpg)
centralized (SVN):
repository
check in!check out
! make changes
![Page 37: Quick intro to Git](https://reader037.vdocuments.us/reader037/viewer/2022102705/54b790a14a7959d7418b4660/html5/thumbnails/37.jpg)
centralized (SVN):
repository
check in!check out
! make changes
check in back to repo
![Page 38: Quick intro to Git](https://reader037.vdocuments.us/reader037/viewer/2022102705/54b790a14a7959d7418b4660/html5/thumbnails/38.jpg)
centralized (SVN):
repository
check in
update
!check out! make changes
check in back to repo
![Page 39: Quick intro to Git](https://reader037.vdocuments.us/reader037/viewer/2022102705/54b790a14a7959d7418b4660/html5/thumbnails/39.jpg)
centralized (SVN):repository
one-to-many relationship
![Page 40: Quick intro to Git](https://reader037.vdocuments.us/reader037/viewer/2022102705/54b790a14a7959d7418b4660/html5/thumbnails/40.jpg)
centralized (SVN):repository
- - -
- -
- - - working copy #1
![Page 41: Quick intro to Git](https://reader037.vdocuments.us/reader037/viewer/2022102705/54b790a14a7959d7418b4660/html5/thumbnails/41.jpg)
centralized (SVN):repository
- - -
- -
- - - working copy #2- - -
- -
- - - working copy #1
![Page 42: Quick intro to Git](https://reader037.vdocuments.us/reader037/viewer/2022102705/54b790a14a7959d7418b4660/html5/thumbnails/42.jpg)
centralized (SVN):repository
- - -
- -
- - - working copy #3
- - -
- -
- - - working copy #2- - -
- -
- - - working copy #1
![Page 43: Quick intro to Git](https://reader037.vdocuments.us/reader037/viewer/2022102705/54b790a14a7959d7418b4660/html5/thumbnails/43.jpg)
centralized (SVN):
• working copies are inferior
![Page 44: Quick intro to Git](https://reader037.vdocuments.us/reader037/viewer/2022102705/54b790a14a7959d7418b4660/html5/thumbnails/44.jpg)
centralized (SVN):
• working copies are inferior
• & can’t talk to each other
![Page 45: Quick intro to Git](https://reader037.vdocuments.us/reader037/viewer/2022102705/54b790a14a7959d7418b4660/html5/thumbnails/45.jpg)
centralized (SVN):
• working copies are inferior
• & can’t talk to each other
• you gotta be online
![Page 46: Quick intro to Git](https://reader037.vdocuments.us/reader037/viewer/2022102705/54b790a14a7959d7418b4660/html5/thumbnails/46.jpg)
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](https://reader037.vdocuments.us/reader037/viewer/2022102705/54b790a14a7959d7418b4660/html5/thumbnails/47.jpg)
distributed (Git):
![Page 48: Quick intro to Git](https://reader037.vdocuments.us/reader037/viewer/2022102705/54b790a14a7959d7418b4660/html5/thumbnails/48.jpg)
distributed (Git):
checkout
![Page 49: Quick intro to Git](https://reader037.vdocuments.us/reader037/viewer/2022102705/54b790a14a7959d7418b4660/html5/thumbnails/49.jpg)
distributed (Git):
checkout
clonewe don’t check out, we cloneclone = full history, can do anything original can
![Page 50: Quick intro to Git](https://reader037.vdocuments.us/reader037/viewer/2022102705/54b790a14a7959d7418b4660/html5/thumbnails/50.jpg)
distributed (Git):
“canonical” repository
"canonical" because it's a social convention, not a technical requirement
![Page 51: Quick intro to Git](https://reader037.vdocuments.us/reader037/viewer/2022102705/54b790a14a7959d7418b4660/html5/thumbnails/51.jpg)
distributed (Git):
!
local repository #1
“canonical” repository
![Page 52: Quick intro to Git](https://reader037.vdocuments.us/reader037/viewer/2022102705/54b790a14a7959d7418b4660/html5/thumbnails/52.jpg)
awesome #1
![Page 53: Quick intro to Git](https://reader037.vdocuments.us/reader037/viewer/2022102705/54b790a14a7959d7418b4660/html5/thumbnails/53.jpg)
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](https://reader037.vdocuments.us/reader037/viewer/2022102705/54b790a14a7959d7418b4660/html5/thumbnails/54.jpg)
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](https://reader037.vdocuments.us/reader037/viewer/2022102705/54b790a14a7959d7418b4660/html5/thumbnails/55.jpg)
awesome #1
local commits#1 #2
![Page 56: Quick intro to Git](https://reader037.vdocuments.us/reader037/viewer/2022102705/54b790a14a7959d7418b4660/html5/thumbnails/56.jpg)
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](https://reader037.vdocuments.us/reader037/viewer/2022102705/54b790a14a7959d7418b4660/html5/thumbnails/57.jpg)
awesome #1
local commits(& revision before pushing)
![Page 58: Quick intro to Git](https://reader037.vdocuments.us/reader037/viewer/2022102705/54b790a14a7959d7418b4660/html5/thumbnails/58.jpg)
distributed (Git):
!
local repository #1
“canonical” repository
![Page 59: Quick intro to Git](https://reader037.vdocuments.us/reader037/viewer/2022102705/54b790a14a7959d7418b4660/html5/thumbnails/59.jpg)
distributed (Git):
!
!
local repository #1
local repository #2
“canonical” repository
![Page 60: Quick intro to Git](https://reader037.vdocuments.us/reader037/viewer/2022102705/54b790a14a7959d7418b4660/html5/thumbnails/60.jpg)
distributed (Git):
“canonical” repository
!
!
local repository #1
local repository #2
![Page 61: Quick intro to Git](https://reader037.vdocuments.us/reader037/viewer/2022102705/54b790a14a7959d7418b4660/html5/thumbnails/61.jpg)
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](https://reader037.vdocuments.us/reader037/viewer/2022102705/54b790a14a7959d7418b4660/html5/thumbnails/62.jpg)
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](https://reader037.vdocuments.us/reader037/viewer/2022102705/54b790a14a7959d7418b4660/html5/thumbnails/63.jpg)
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](https://reader037.vdocuments.us/reader037/viewer/2022102705/54b790a14a7959d7418b4660/html5/thumbnails/64.jpg)
workflows
![Page 65: Quick intro to Git](https://reader037.vdocuments.us/reader037/viewer/2022102705/54b790a14a7959d7418b4660/html5/thumbnails/65.jpg)
centralizedbasically like SVN but nicer
![Page 66: Quick intro to Git](https://reader037.vdocuments.us/reader037/viewer/2022102705/54b790a14a7959d7418b4660/html5/thumbnails/66.jpg)
integration manager
blessed repo, integration manager, many devs.“open-source model”.
![Page 67: Quick intro to Git](https://reader037.vdocuments.us/reader037/viewer/2022102705/54b790a14a7959d7418b4660/html5/thumbnails/67.jpg)
dictator&
lieutenantsfor massive projects, like Linux Kernel
![Page 68: Quick intro to Git](https://reader037.vdocuments.us/reader037/viewer/2022102705/54b790a14a7959d7418b4660/html5/thumbnails/68.jpg)
infiltrationa howto
start using Git tomorrow without anyone suspecting a thing.
![Page 69: Quick intro to Git](https://reader037.vdocuments.us/reader037/viewer/2022102705/54b790a14a7959d7418b4660/html5/thumbnails/69.jpg)
git-svn
![Page 70: Quick intro to Git](https://reader037.vdocuments.us/reader037/viewer/2022102705/54b790a14a7959d7418b4660/html5/thumbnails/70.jpg)
$ 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](https://reader037.vdocuments.us/reader037/viewer/2022102705/54b790a14a7959d7418b4660/html5/thumbnails/71.jpg)
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](https://reader037.vdocuments.us/reader037/viewer/2022102705/54b790a14a7959d7418b4660/html5/thumbnails/72.jpg)
Nothing is perfect
SVN handles binary files better
SVN allows partial check outs
![Page 73: Quick intro to Git](https://reader037.vdocuments.us/reader037/viewer/2022102705/54b790a14a7959d7418b4660/html5/thumbnails/73.jpg)
git-scm.com#git on Freenode
github.com
MOAR:
Trac + Sourceforge + Facebook :]
![Page 74: Quick intro to Git](https://reader037.vdocuments.us/reader037/viewer/2022102705/54b790a14a7959d7418b4660/html5/thumbnails/74.jpg)
Questions