Tech thursdays / GIT

84
Będzie Git mam nadzieje...

Transcript of Tech thursdays / GIT

Page 1: Tech thursdays / GIT

Będzie Gitmam nadzieje...

Page 2: Tech thursdays / GIT

Git / Why should I care?

http://www.google.com/trends/explore#cat=0-5-32&q=git%2C%20subversion%2C%20mercurial&cmpt=q

Page 3: Tech thursdays / GIT

Git / What is Git ?

Git is an open source distributed version control system designed for speed and efficiency.

Initially designed and developed by Linus Torvalds for Linux kernel development.

Page 4: Tech thursdays / GIT

Git / What is Git ?

Git is an open source distributed version control system designed for speed and efficiency.

Initially designed and developed by Linus Torvalds for Linux kernel development.

Page 5: Tech thursdays / GIT

Git / What's Linus likes ?

Page 6: Tech thursdays / GIT

Git / What's Linus likes ?

Page 7: Tech thursdays / GIT

Git / Open Source

Git is an open source distributed version control system designed for speed and efficiency.

Initially designed and developed by Linus Torvalds for Linux kernel development.

Page 8: Tech thursdays / GIT

Git / Distributed

Git is an open source distributed version control system designed for speed and efficiency.

Initially designed and developed by Linus Torvalds for Linux kernel development.

Page 9: Tech thursdays / GIT

Git / Central vs Distributed

Computer A

checkout

file

Computer

checkout

file

Central VCS

version database

version 1

version 2

version 3

Page 10: Tech thursdays / GIT

Git / Central vs Distributed

Computer A

version database

file

version 1

version 2

Computer A

version database

file

version 1

version 2Server Computer

version database

version 1

version 2

Page 11: Tech thursdays / GIT

Git / Efficiency

Git is an open source distributed version control system designed for speed and efficiency.

Initially designed and developed by Linus Torvalds for Linux kernel development.

Page 12: Tech thursdays / GIT

Git / Efficiency

Not a shrink wrap product, so not quite what we are doing, however facebook have 700 developers, with new code pushed out daily

http://venturebeat.com/2012/08/03/facebook-code/

Our merging process seems to have slowed down, where merges are now held until the end of the iteration. We need to become more rapid and have user stories accepted earlier in the iteration cycle, with more regular and smaller merges taking place throughout the iteration.

Cheers,

XXX

Software Development Engineering Manager

Page 13: Tech thursdays / GIT

Git / Efficiency

Page 14: Tech thursdays / GIT

Git / Efficiency

Page 15: Tech thursdays / GIT

Git /Efficiency

$time to deliver (time to market) + additional costs (disk space,..)

=methodologies

version control systemopen-source projects

programming languages (functional/lambda = less code)modular architecture

continuous integrationtest automation

continuous deploymentmonitoring driven development

Page 16: Tech thursdays / GIT

Git / Delta based storage

Commit 1 Commit 2 Commit 3 Commit 4 Commit 5

index.html

style.css

main.js

Δ1

Δ2

Δ3

Δ5

Δ7

Δ8

homt.html Δ6

Page 17: Tech thursdays / GIT

Git / Delta based storage

Commit 1 Commit 2 Commit 3 Commit 4 Commit 5

index.html

style.css

main.js

Δ1

Δ2

Δ3

Δ5

Δ7

Δ8

homt.html Δ6

Page 18: Tech thursdays / GIT

Git / Delta based storage

Commit 1 Commit 2 Commit 3 Commit 4 Commit 5

index.html

style.css

main.js

Δ1

Δ2

Δ3

Δ5

Δ7

Δ8

homt.html Δ6

Page 19: Tech thursdays / GIT

Git / Delta based storage

Commit 1 Commit 2 Commit 3 Commit 4 Commit 5

index.html

style.css

main.js

Δ1

Δ2

Δ3

Δ5

Δ7

Δ8

homt.html Δ6

Page 20: Tech thursdays / GIT

Git / Delta based storage

Commit 1 Commit 2 Commit 3 Commit 4 Commit 5

index.html

style.css

main.js

Δ1

Δ2

Δ3

Δ5

Δ7

Δ8

homt.html Δ6

Page 21: Tech thursdays / GIT

Git / Delta based storage

Commit 1 Commit 2 Commit 3 Commit 4 Commit 5

index.html

style.css

main.js

Δ1

Δ2

Δ3

Δ5

Δ7

Δ8

homt.html Δ6

Page 22: Tech thursdays / GIT

Git / Direct Acyclic Graph Storage

Commit 1 Commit 2 Commit 3 Commit 4 Commit 5

entity 1

entity 2

entity 3

entity 4

entity 5

entity 6

entity 8

entity 9

entity 0

entity 7 entity 6

Page 23: Tech thursdays / GIT

Git / Direct Acyclic Graph

Directed GraphArcs Connecting the nodes are directional.

Page 24: Tech thursdays / GIT

Git / Direct Acyclic Graph

A->B->C->D->Ais a CYCLEAcyclic graphs have NO CYCLES

A

C

B

D

Page 25: Tech thursdays / GIT

Git / Source control taxonomy

delta storage

local

centralized

distributed

rcs

cvs cvs perforce

darcs mercurial

dag storage

local

centralized

distributed

cp -r time machine

bitkeeper

git bazaar

Page 26: Tech thursdays / GIT

Git / Meat

.gitconfig file

hooksindex

object databasereferences

Page 27: Tech thursdays / GIT

Git / Object database

.gitconfig file

hooksindex

object databasereferences

Page 28: Tech thursdays / GIT

Git / Object database / Algorithm

new_content = type + ’ ‘ + content.size + \0+ content

sha = Digest::SHA1.hexdigest(new_content)“824aed035c0aa75d64c...”

compressed = zlib::deflate(new_content)

path = “.git/objects/82/4aed035c0aa75d64c...”

File.open(path, ‘w’) {|f| f.write(compressed)}

http://alblue.bandlem.com/2011/08/git-tip-of-week-objects.html

Page 29: Tech thursdays / GIT

Git / Object database / GC

git gc.git/objects/82/4aed035c0aa75d64c....git/objects/1d/c9cbcb76cbb80fce1....git/objects/63/874f37013c1740acd....git/objects/04/fb8aee105e6e445e8...

.git/objects/45/b983be36b73c0788d....git/objects/f1/032eed02413a1145c...

.git/objects/pack/pack-999727..9f600.pack.git/objects/pack/pack-999727..9f600.idx

http://alblue.bandlem.com/2011/09/git-tip-of-week-objects-and-packfiles.html

Page 30: Tech thursdays / GIT

Git / Object database

blob tree

commit tag

Page 31: Tech thursdays / GIT

FILE===============srutu tutu majtki z drutu

Git / Object database / Blob

blob [content size]\0

blob : a906cb

zlib::deflate

http://alblue.bandlem.com/2011/09/git-tip-of-week-objects-and-packfiles.html

Page 32: Tech thursdays / GIT

Git / Object database / Tree

./

blob : a874b7

blob : a906cb

tree : fe8971

blob : a0a60a

tree : 1a738d

index.html

js/

main.js

README

Page 33: Tech thursdays / GIT

100644 blob a874b7 README100644 blob a906cb index.html040000 tree fe8971 js

Git / Object database / Tree

tree [content size]\0

tree : 1a738d

zlib::deflate

http://alblue.bandlem.com/2011/08/git-tip-of-week-trees.html

Page 34: Tech thursdays / GIT

Git / Object database / Commit

commit

blob

blob

tree

blob

tree

tree

Page 35: Tech thursdays / GIT

http://alblue.bandlem.com/2011/09/git-tip-of-week-commits.html

tree e1b3ecparent a11befauthor Marek Prochera

<[email protected]> 1205624433committer Marek Prochera

<[email protected]> 1205624433my second commit

Git / Object database / Commit

commit [content size]\0

commit : e1b3ec

zlib::deflate

Page 36: Tech thursdays / GIT

Git / Object database / Tag

tag

tree

blob

commit

Page 37: Tech thursdays / GIT

object 0576fatype committag v0.1tagger Marek Prochera

<[email protected]> 1205624655this is my v0.1 tag

Git / Object database / Tag

tag [content size]\0

tag : 0c819c

zlib::deflate

http://alblue.bandlem.com/2011/04/git-tip-of-week-tags.html

Page 38: Tech thursdays / GIT

Git / Object database

blob treeimmutable! fuck yea!

commit tag

Page 39: Tech thursdays / GIT

Git / References

.gitconfig file

hooksindex

object databasereferences

Page 40: Tech thursdays / GIT

Referenceslightweight, movable pointers to a commit

stored in .git/refs/* as file

Git / References

HEAD

blob

commit

branch

tree

tagremote

Page 41: Tech thursdays / GIT

Git / Object db + Refs / Use case

git checkout v.01

.git/refs/tags/v0.1 "0c819c"

tag: 0c819c

commit : a11bef

tree : 1a738d

README blob : a874b7

Page 42: Tech thursdays / GIT

Git / References

commit historybranching and merging

remotes...

Page 43: Tech thursdays / GIT

Git / Treeish

alternate ways to refer toobjects or ranges of objects

• full sha-1• partial sha-1

• branch or tag name• date spec

• ordinal spec• carrot parent

• tilde spec• tree pointer

• blob spec• ranges

Page 44: Tech thursdays / GIT

Git / Treeish / Full sha-1

6e453f523fa1da50ecb04431101112b3611c6a4d

Page 45: Tech thursdays / GIT

Git / Treeish / Partial sha-1

6e453f523fa1da50ecb04431101112b3611c6a4d6e453f523fa1da50

6e453

Page 46: Tech thursdays / GIT

Git / Treeish / Branch, remote, tag

v1.0master

origin/kuciap

Page 47: Tech thursdays / GIT

Git / Treeish / Ordinal Spec

master@{5}5th prior value of ‘master’

Page 48: Tech thursdays / GIT

Git / Treeish / Tidle Spec

master~22nd generation grandparent of ‘master’

Page 49: Tech thursdays / GIT

Git / Treeish / Tree Pointer

master^{tree}tree that ‘master’ points to

Page 50: Tech thursdays / GIT

Git / Treeish / Blob spec

master:/path/to/fileblob of that file in ‘master’ commit

Page 51: Tech thursdays / GIT

Git / Treeish / Ranges

ce0e4..e4272everything between two commits

Page 52: Tech thursdays / GIT

Git / Index

.gitconfig file

hooksindex

object databasereferences

Page 53: Tech thursdays / GIT

Git / Index

working directory

repository

index

git add ...

git commit ...

http://alblue.bandlem.com/2011/10/git-tip-of-week-understanding-index.html

Page 54: Tech thursdays / GIT

Git / Hooks

.gitconfig file

hooksindex

object databasereferences

Page 55: Tech thursdays / GIT

hooks = automation :)fuck yea!

Git / Hooks

Page 56: Tech thursdays / GIT

Git / Config

.gitconfig file

hooksindex

object databasereferences

Page 57: Tech thursdays / GIT

config = config :)

Git / Config

Page 58: Tech thursdays / GIT

Over 152 commands

42 porcelain

110 plumbing

Git / Git Playground

Page 59: Tech thursdays / GIT

Git / ID

git config --global user.name “Marek Prochera”

git config --global user.email “[email protected]

mpr:~ marek$ cat ~/.gitconfig [user]

name = Marek Procheraemail = [email protected]

Page 60: Tech thursdays / GIT

Git / Clone

mpr:tmp marek$ git clone [email protected]:playframework/Play20.gitCloning into 'Play20'...

remote: Counting objects: 43846, done.remote: Compressing objects: 100% (17930/17930), done.

remote: Total 43846 (delta 22410), reused 40397 (delta 19382)Receiving objects: 100% (43846/43846), 57.74 MiB | 3.41 MiB/s, done.

Resolving deltas: 100% (22410/22410), done.

Page 61: Tech thursdays / GIT

Git / and so on...

git init git add -A

git commit -a -m "Initial commit"git status

git loggit log --pretty=oneline

git log --pretty=format: %h %an %ar - %sgit diff (treeish1) (treeish2)

Page 62: Tech thursdays / GIT

Git / and so on...

git branchgit show-branch

git checkout -b featuregit merge fature

git rebase

Page 63: Tech thursdays / GIT

Git / Merge & rebase

develop

master

C 0 C 7

C 3

C 6

C 4 C 5

develop

master

C 0 C 6'C 3 C 4 C 5

Page 64: Tech thursdays / GIT

Git / and so on...

mpr:test2 marek$ git remote add krogulec [email protected]:playframework/Play20.git

mpr:test2 marek$ git remote -vkrogulec [email protected]:playframework/Play20.git (fetch)krogulec [email protected]:playframework/Play20.git (push)

Page 65: Tech thursdays / GIT

Git / and so on...

git remote show krogulecpush / pull krogulec master

pull = fetch + merge

Page 66: Tech thursdays / GIT

no more scm document!

Git / Workflows

Page 67: Tech thursdays / GIT

Git / Repo model / Shared

shared repository

dev 2dev 1

Page 68: Tech thursdays / GIT

Git / Workflows

shared repository

dev 2dev 1

Page 69: Tech thursdays / GIT

Git / Repo ... / dictator and lieutenants

blessed repository

dev 2

dev 1

lieutenants

dictator

lieutenants

Page 70: Tech thursdays / GIT

Git / Repo ... / Integration manager

blessed repository

dev 2

dev 1

dev 1 public repo

integration manager

dev 2 public repo

Page 71: Tech thursdays / GIT

Git / Git-Flow

Page 72: Tech thursdays / GIT

Git / Git-Flow

http://nvie.com/posts/a-successful-git-branching-model/

https://github.com/nvie/gitflow

......git flow release

git flow release start <release> [<base>]git flow release finish <release>

Page 73: Tech thursdays / GIT

Git / Repos

Provider Git Mercurial Free Priv Rep Premium

github

bitbucket

X

X !!!

X

X X

your own EC2 !!! !!!!!! !!!

http://www.wikivs.com/wiki/Git_vs_Mercurial#Hosting_Provider_Support

Page 74: Tech thursdays / GIT

Git / Git as a SVN client

git as a client:do not mess in history !

sudo apt-get install git-svngit svn init svn://repo.path/trunk

git svn fetch -r HEAD

pull:git svn rebase

push:git svn dcommit

http://trac.parrot.org/parrot/wiki/git-svn-tutorial

Page 75: Tech thursdays / GIT

Git / Tools/IDE support

Page 76: Tech thursdays / GIT

Git / Tools/IDE support / Git alias

#make "com" alias for "commit"

git config alias.com commit

#make "co" alias for checkout

git config alias.co checkout

#make "br" alias for branch

git config alias.br branch

# When you want to see just the differences of one function in one file in two different commits

git config alias.funcdiff '!sh -c "git show \"\$1:\$3\" | sed -n \"/^[^ \t].*\$4(/,/^}/p\" > .tmp1 &&

git show \"\$2:\$3\" | sed -n \"/^[^ \t].*\$4(/,/^}/p\" > .tmp2 &&

git diff --no-index .tmp1 .tmp2"' -

Page 77: Tech thursdays / GIT

Git / Tools/IDE support / bash

https://github.com/magicmonty/bash-git-prompt

Page 78: Tech thursdays / GIT

Git / Tools/IDE support

Repository management (ssh keys, privileges ): gitosishttps://wiki.archlinux.org/index.php/Gitosis

Web based browsers:https://wiki.archlinux.org/index.php/Gitweb

Browser + code review:https://code.google.com/p/gerrit/

http://www.codebrag.com/

Page 79: Tech thursdays / GIT

Git / Tools/IDE supportIntelliJ IDEA as always the best :)

egit in eclipse sucks

most of good GUI tools for git are dedicated for Mac OSX :/http://git-scm.com/downloads/guis

linuxgitk / gitg

(http://git.gnome.org/browse/gitg)

Page 80: Tech thursdays / GIT

Git / Tools/IDE supportIntelliJ IDEA as always the best :)

egit in eclipse sucks

most of good GUI tools for git are dedicated for Mac OSX :/http://git-scm.com/downloads/guis

linuxgitk / gitg

(http://git.gnome.org/browse/gitg)

Page 81: Tech thursdays / GIT

Git / Tools/IDE support

but if you like ponies ... you're lucky!

SourceTree @ Atlassianhttp://www.atlassian.com/software/sourcetree/overview

Git Bash!

Page 83: Tech thursdays / GIT

Git / Resources

https://www.google.com/search?q=git

http://alblue.bandlem.com/Tag/git/http://gitref.org/

ProGit (EN/PL) http://git-scm.com/

Git. Rozproszony system kontroli wersji (PL)http://helion.pl/ksiazki/git-rozproszony-system-kontroli-wersji-wlodzimierz-gajda,gitroz.htm

http://pcottle.github.io/learnGitBranching/

Page 84: Tech thursdays / GIT

Git / This is the end

Thank you