tech thursdays / git
TRANSCRIPT
Będzie Gitmam nadzieje...
Git / Why should I care?
http://www.google.com/trends/explore#cat=0-5-32&q=git%2C%20subversion%2C%20mercurial&cmpt=q
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.
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.
Git / What's Linus likes ?
Git / What's Linus likes ?
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.
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.
Git / Central vs Distributed
Computer A
checkout
file
Computer
checkout
file
Central VCS
version database
version 1
version 2
version 3
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
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.
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
Git / Efficiency
Git / Efficiency
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
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
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
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
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
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
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
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
Git / Direct Acyclic Graph
Directed GraphArcs Connecting the nodes are directional.
Git / Direct Acyclic Graph
A->B->C->D->Ais a CYCLEAcyclic graphs have NO CYCLES
A
C
B
D
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
Git / Meat
.gitconfig file
hooksindex
object databasereferences
Git / Object database
.gitconfig file
hooksindex
object databasereferences
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
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
Git / Object database
blob tree
commit tag
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
Git / Object database / Tree
./
blob : a874b7
blob : a906cb
tree : fe8971
blob : a0a60a
tree : 1a738d
index.html
js/
main.js
README
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
Git / Object database / Commit
commit
blob
blob
tree
blob
tree
tree
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
Git / Object database / Tag
tag
tree
blob
commit
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
Git / Object database
blob treeimmutable! fuck yea!
commit tag
Git / References
.gitconfig file
hooksindex
object databasereferences
Referenceslightweight, movable pointers to a commit
stored in .git/refs/* as file
Git / References
HEAD
blob
commit
branch
tree
tagremote
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
Git / References
commit historybranching and merging
remotes...
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
Git / Treeish / Full sha-1
6e453f523fa1da50ecb04431101112b3611c6a4d
Git / Treeish / Partial sha-1
6e453f523fa1da50ecb04431101112b3611c6a4d6e453f523fa1da50
6e453
Git / Treeish / Branch, remote, tag
v1.0master
origin/kuciap
Git / Treeish / Ordinal Spec
master@{5}5th prior value of ‘master’
Git / Treeish / Tidle Spec
master~22nd generation grandparent of ‘master’
Git / Treeish / Tree Pointer
master^{tree}tree that ‘master’ points to
Git / Treeish / Blob spec
master:/path/to/fileblob of that file in ‘master’ commit
Git / Treeish / Ranges
ce0e4..e4272everything between two commits
Git / Index
.gitconfig file
hooksindex
object databasereferences
Git / Index
working directory
repository
index
git add ...
git commit ...
http://alblue.bandlem.com/2011/10/git-tip-of-week-understanding-index.html
Git / Hooks
.gitconfig file
hooksindex
object databasereferences
hooks = automation :)fuck yea!
Git / Hooks
Git / Config
.gitconfig file
hooksindex
object databasereferences
config = config :)
Git / Config
Over 152 commands
42 porcelain
110 plumbing
Git / Git Playground
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]
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.
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)
Git / and so on...
git branchgit show-branch
git checkout -b featuregit merge fature
git rebase
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
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)
Git / and so on...
git remote show krogulecpush / pull krogulec master
pull = fetch + merge
no more scm document!
Git / Workflows
Git / Repo model / Shared
shared repository
dev 2dev 1
Git / Workflows
shared repository
dev 2dev 1
Git / Repo ... / dictator and lieutenants
blessed repository
dev 2
dev 1
lieutenants
dictator
lieutenants
Git / Repo ... / Integration manager
blessed repository
dev 2
dev 1
dev 1 public repo
integration manager
dev 2 public repo
Git / Git-Flow
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>
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
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
Git / Tools/IDE support
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"' -
Git / Tools/IDE support / bash
https://github.com/magicmonty/bash-git-prompt
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/
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)
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)
Git / Tools/IDE support
but if you like ponies ... you're lucky!
SourceTree @ Atlassianhttp://www.atlassian.com/software/sourcetree/overview
Git Bash!
Git / Git vs Hg
If you just give them a chance....
http://felipec.wordpress.com/2012/05/26/no-mercurial-branches-are-still-not-better-than-git-ones-response-to-jhws-more-on-mercurial-vs-git-with-graphs/
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/
Git / This is the end
Thank you