Designing IA for AI - Information Architecture Conference 2024
Git workshop 33degree 2011 krakow
1. Git Luca Milanesio Android programming Sang Shin The Productive Programmer Neal Ford The Power of Retrospection Linda Rising Introduction to Scala Hubert Plociniczak Main sponsor
2. Agenda SCM and Git Concepts Git quick start Branching and merging Resolving conflicts Reverting changes Working with tags Git remotes Git on the server Git peer-to-peer Git democracy
3. Who’s that guy ? Luca MilanesioLMIT Limited – Director / co-founder of GitEnterprise.com Jenkins (formerly Hudson) contributor since 2007founder of hudson-mobi.com Over 18 years of experience in Software and Services Development and Application Lifecycle Worked for major UK, EU and US Customers Banking, Retailers, Industry, Finance, Telecoms, Utilities, Government Git enthusiast since 2009 and innovator in Vodafone Group Services Ltd
10. … and much more Picture courtesyofglobalnerdy.com - Allrightskindlyreserved
11. Brief history of OpenSourceSCMs Local SCMs (versions kept on local filesystem) SCCS (1972) … I was not yet born, don’t remember RCS (1982) the most widely used on Unix Server-based SCMs (central repository server) CVS (1990) first widely used SCM server Subversion (2000) first widely Internet SCM … and then let’s to go distributed … DCVS (2002) who has ever used it ? Mercurial and Git (2005)
12. Centralised vs. distributed ? How many of you are using central repositories ? CVS-boys … raise your hands ! SVN-guys … it’s your turn ! How many are for distributed repositories ? Mercurial-scientists ... raise your hands ! Git-explorers … brave men !
13. Who’s right ? Central SCM Unique “source of truth” Central back-up Seamless alignment for all developers Security and access control Distributed SCM Community code-base No single-point-of-failure Peer-to-peer alignment Continuous branching and merging
14. Why GIT ? It’s all about BitKeeper fault: they broke up with LinusTorvalds … and I’m not kidding Story: Linux Kernel SCM: BitKeeper Apr 2005 – Linus writes PERL scripts for Linux Kernel SCM Jul 2005 … Git 0.99 is out ! Git principles: Allow the BitKeeper SCM workflow Use CVS as the “not-to-do” example Check and prevent corruption Make it FFF … FAST FAST FAST !
17. Git installation (Ver. >=1.6) Linux (Gitfavourite of course !) Ubuntu: sudo apt-get install git-core other Linux ? … best from source codehttp://git-scm.com/ Mac OSX http://code.google.com/p/git-osx-installer/ Windows http://code.google.com/p/msysgit/(sucks … but it’s your fault not using Unix) CygwinHIGHLY RECOMMENDED (mandatory IMHO)
34. Git stores the whole file Git is different from SVN: no diffs, just whole files Git stores changed files between snapshots(BitKeeperdocet) Picture courtesyofProGit.org
35. Git object types: blobs Git stores all files (and their versions) as objects (blobs) Each object has a SHA-1 160-bit identifier SHA-1 provides: Unique Global ID Integrity check Example: File content: “You're GIT too” SHA-1: bbecf72783dfba9e0243e13dbb5fb04ed39ed4e4 (Hex) Track content (not files) Automatically detect renames … cool !
36. SHA-1 ? WTF … Why LinusTorvalds has chosen SHA-1 hashing ? Need for track content globally SHA-1 collision probability is 1/251 What happens if two files have same SHA-1 ? BOOM ! What is the probability of it ? World’s population (7 BN people)sharing files of 10 times Linux Kernel Possible ? More likely to be hit by a 15 KM asteroid NOW !!!
37. Git object types: commits and trees Git tree identifies a snapshot (set of files) Git commit identifies Author / Committer Commit message Timestamp Tree Picture courtesyofProGit.org
38. Git history: graph of commits Every commit points to its predecessor Series of commits make Git repository history Picture courtesyofProGit.org
39. Where are Git objects ? Git objects are in .git/objects SHA-1 identify directory / file
40. Curious about Git objects ? Git objects are compressed Use git show to display content
41. Getting lost ? How to remember SHA-1 hashing codes ? How Git stores the “pointers” to Commit graph ? Git references are the solution ! Head of the Git history Intermediate tags Branch points Relative points
42. Git references References: “labels” for Git SHA-1 commit IDs Stored as files under .git/refs Reference types: Tags Heads (branches) HEAD is a special ref:always points tohead of currentbranch.
43. How Git commits graph looks like ? Reference Commit Tree Picture courtesyofProGit.org
44. What is a branch for Git ? Git named branch = reference to a commit ID (head of branch) Git supports “network” of commits, with named and unnamed branches … don’t know why Git reminds me some “underground” branches
45. Real-life Git branches Think I’m exaggerating ? Look at this example (it’s real, swear !)
47. Wear “life jacket” first Get Git bash extensions source git/contrib/completion/git-completion.bash Redefine promptexport PS1='$(__git_ps1 " (%s)") ’ ... and your current branch is visible on your prompt: you will not get lost
52. Git graph after merge Let’s have a look on the result with gitk Merge-type applied: Fast-forward (move refs in history) Branch has been “flattened” Experimental just another ref to master
53. Git recursive-merge Let’s create some divergence Changes on both master and experimental Fast-forward merge = move branch ref to another commit ID
54. Git diverging branches Use gitk --all to display all branchesNOTE: no args displays just current branch experimental is really diverging from master
55. Git recursive merge Let’s merge again with master This is a real merge folks ! NOTE: Merge is a Git commit: you can associate a comment, or revert it later ! Don’t be scared by Git-managed merge
57. Git rebase in action Let’s diverge again between master and experimental Magic ! … rebase flattens the branching history
58. Git graph after rebase Experimental is no more a diverging branch NOTE: Marconi’s test is on “unnamed branch” and experimental branch history has changed !
75. Git is powerful and dangerous Git has full control on history Amend existing commits Remove commits Revert changes Be careful: you could destroy your history ! Be even more careful: history revert is unrecoverable SCARY !!!!!
76. Change existing commits Git commit support the “amend” option to overwrite committed data What can be amended File changes Author / comment Date The original commit will disappear: amend is NOT revertible (but just amended again)
79. Git reset: back to the past Git reset allows to: Put committed data back to the working dir soft reset Remove completely committed data hard reset Git reset is NOT revertible You want to reset ? Do you really need it ? Do you really want it ? What do you want to achieve ? … and then think again …
80. Soft reset Remove the last commit and put changes back to workdir Hint: master~1 = reference to “one commit before master head” Commit is lost, but you still have the changes in workdir
81. Hard reset Remove commit and all the changes associated Commit is lostFOREVER: there is no way to restore the data
82. Git revert Git revert allows to: Revert the changes and to workdir Revert the changes and create a “reverted commit” Git revert is revertible Revert = negative commit (eliminates effect of reverted commit)
87. Importance of Git tags Why using tags ? … yeah, you know it Why is MORE IMPORTANT in Git than in SVN ? Git commit IDs is SHA-1 hashing (WTF $!#@$!%@^!) Tags = reference to a commit (zero payload) Type of Git tags Lightweight tags (simple Git ref to a commit ID) Annotated tags (author, description, signature)
88. Lightweight tags Let’s create a lightweight tag … that’s easier to remember than b7dbbe69f0be…. !
89. Fully annotate tags Fully annotated tags contains meta-data: Timestamp Author name and e-mail Description Commit ID GPG Digital Signature Create your private GPG Key-pair first GPG Public Key identify your user GPG Private Key is used to sign content (tags, commits) Exchange GPG Public Key with your peers
93. Git nature: peer-to-peer distributed Git designed to be distributed Global unique IDs for files and commits (SHA-1) Completely disconnected operations Rich set of merging capabilities Compression and integrity check Natural way of using it is peer-to-peer … the Linus way, yeah
94. Remote Git repositories Points to other’s people repository Remote Git servers / location Remote Git branches Example: clone GIT source code repository via “remote” git clone git://git.kernel.org/pub/scm/git/git.git
95. Inspecting remote pointers List of remote Git repositories Name “origin” refers to remote Git repository List of remote Git branches
96. Push changes to remote Git repository Add pointer to remote Git repository Push all local branches to remote Git repository
101. Public Git Server: github Many choices … but github is the best ! Create your SSH Key-pairssh-keygen -trsa -b 2048 Create your free acount on: https://github.com/signup/free Create your repository on:https://github.com/repositories/new Add your remotegit remote add origin git@github.com:lucamilanesio/33degree.git
102. Private Git Server: GitEnterprise Many choices … but this is the best for FREE Create your SSH Key-pair (optional: you can use HTTP/basic auth, firewall frendly)ssh-keygen -trsa -b 2048 Create your free acount on: https://gitent-scm.com/gitent/users/SignUp.git Create your repository on:https://gitent-scm.com/gitent/repository/RepositoryCreation.git Add your remotegit remote add origin ssh://lmilanesio@gitent-scm.com/git/gitentdevelopment/33degree
103. 3rd choice: make your own ! Installed on your network, running on your hardware NOTE: make daily backups … GIT is dangerous ! Gitosis (http://eagain.net/gitweb/?p=gitosis.git) Users / Groups / Keys Repository management Everything managed with Git Management Repository Gerrit (http://code.google.com/p/gerrit/) Full Web-based Interface Users / Groups integrated with LDAP, OpenID, … Full repository and security management Full code-review lifecycle management
105. Everybody fetch/pull from each other Anna John Cathy Linus Luke Peter Nobody pushes: everybody fetch or pull Every Git repository has the same importance
106. How does it work ? Run your own Git server with git daemon Others can clone and fetch from your repository You see them fetching
108. Developers fetch/pull, dictator pushes git push Developers pull, Lieutenants integrate Dictator get integration branches together: he is the only one that PUSH to Git Picture courtesyofProGit.org
109. GitHub variant git push Developers pull from “blessed” and have their own public Git Integration manager is the Dictator Revolution allowed: developer nominates himself “new dictator” Picture courtesyofProGit.org
111. Unique central repository Everybody can push / pull from shared Git Repository Central repository dies elections of new repository Picture courtesyofProGit.org
112. Back to centralisation ? WTF ? Does it seems like SVN ? … much more guys Git Democracy vs. SVN Horizontal collaboration between developers (P2P) Continuous branching / merging “promotions” of changes through voting (Gerrit model) Control over integration / release Does it seems like Git is mature for the Enterprise ?
114. Working with topic branches Developers work on topics Code-review / votes promote them to master Topics branches removed after merge NOTE: better rebase than merge Picture courtesyofProGit.org
115. Topic branches example Developer A starts working on topic-1 Developer B starts working on topic-2
116. Code-review: merge topic-1 Get topic-1 code and code-review on integration branch Everything’s fine: commit the merge and remove topic-1
118. Release manager: merge integration Release manager decides about releasing integration branch NOTE: No conflicts are generated all merges are from integration branch
119.
120.
121.
122. BOF: Hack your company Jakub Nabrdalik BOF: Web framework shootout Błażej Bucko, Tomasz Dziurko, Wojciech Erbetowski, Łukasz Kuczera, Paweł Szulc BOF: Future of Java EE Alexis Moussine-Pouchkine BOF: Those broken, broken class loaders JevgeniKabanov Main sponsor