Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
SlideShare a Scribd company logo
GitLuca MilanesioAndroid programmingSang ShinThe Productive ProgrammerNeal FordThe Power of RetrospectionLinda RisingIntroduction to ScalaHubert PlociniczakMain sponsor
AgendaSCM and Git ConceptsGit quick startBranching and mergingResolving conflictsReverting changesWorking with tagsGit remotesGit on the serverGit peer-to-peerGit democracy
Who’s that guy ?Luca MilanesioLMIT Limited – Director / co-founder of GitEnterprise.comJenkins (formerly Hudson) contributor since 2007founder of hudson-mobi.comOver 18 years of experience in Software and Services Development and Application LifecycleWorked for major UK, EU and US CustomersBanking, Retailers, Industry, Finance, Telecoms, Utilities, GovernmentGit enthusiast since 2009 and innovator in Vodafone Group Services Ltd
About SCM … remember ?SCM = Source Code ManagementMultiple revisions of files
Commit and rollback changes
Define change-sets
Tag important releases
Manage branches of development
Integrate the work of multiple teams together
… and much more Picture courtesyofglobalnerdy.com - Allrightskindlyreserved
Brief history of OpenSourceSCMsLocal SCMs (versions kept on local filesystem)SCCS (1972) … I was not yet born, don’t remember RCS (1982) the most widely used on UnixServer-based SCMs (central repository server)CVS (1990) first widely used SCM serverSubversion (2000) first widely Internet SCM… and then let’s to go distributed …DCVS (2002) who has ever used it ?Mercurial and Git (2005)
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 !
Who’s right ?Central SCMUnique “source of truth”Central back-upSeamless alignment for all developersSecurity and access controlDistributed SCMCommunity code-baseNo single-point-of-failurePeer-to-peer alignmentContinuous branching and merging
Why GIT ?It’s all about BitKeeper fault: they broke up with LinusTorvalds … and I’m not kidding Story:Linux Kernel SCM: BitKeeperApr 2005 – Linus writes PERL scripts for Linux Kernel SCMJul 2005 … Git 0.99 is out !Git principles:Allow the BitKeeper SCM workflowUse CVS as the “not-to-do” exampleCheck and prevent corruptionMake it FFF … FAST FAST FAST !
BORED of too much theory ?
Let’s experimentGit in action !
Git installation (Ver. >=1.6)Linux (Gitfavourite of course !)Ubuntu: sudo apt-get install git-coreother Linux ? … best from source codehttp://git-scm.com/Mac OSXhttp://code.google.com/p/git-osx-installer/Windowshttp://code.google.com/p/msysgit/(sucks … but it’s your fault not using Unix)CygwinHIGHLY RECOMMENDED (mandatory IMHO)
Step 1 – Git repositorycreate project
cd into project
$ git initStep 2 – Git identityDefine your full name
Define your e-mail
Everything stored in .git/configStep 3 – Add some files and commitCreate some files
Add to GIT (default = recursive)
CommitStep 4 – Inspect GIT logGet GIT history of commits
Display changesToo simple ? … let’s add some statesThree states of Git files1. Unstaged2. Staged3. Cleangit addgit commitPicture courtesyofProGit.org
State 1. unstagedCreate a new fileChange an existing fileCheck status
State 2. stagedAdd the two files to staging areaCheck status
State 3. work directory cleanCommit the staging areaCheck status
Display Git lifecycleAdd another file and make some changes$ gitgui
Stage with gitguiSelect files and chose “Stage to commit”
Commit with gitguiEnter commit message and click “commit”
Git graph log with gitk
Playtime is over 
Git stores the whole fileGit is different from SVN: no diffs, just whole filesGit stores changed files between snapshots(BitKeeperdocet)Picture courtesyofProGit.org
Git object types: blobsGit stores all files (and their versions) as objects (blobs)Each object has a SHA-1 160-bit identifierSHA-1 provides:Unique Global IDIntegrity checkExample:File content: “You're GIT too”SHA-1: bbecf72783dfba9e0243e13dbb5fb04ed39ed4e4 (Hex)Track content (not files)Automatically detect renames … cool !
SHA-1 ? WTF …Why LinusTorvalds has chosen SHA-1 hashing ?Need for track content globallySHA-1 collision probability is 1/251What 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 !!!
Git object types: commits and treesGit tree identifies a snapshot (set of files)Git commit identifiesAuthor / CommitterCommit messageTimestampTreePicture courtesyofProGit.org
Git history: graph of commitsEvery commit points to its predecessorSeries of commits make Git repository historyPicture courtesyofProGit.org
Where are Git objects ?Git objects are in .git/objectsSHA-1 identify directory / file
Curious about Git objects ?Git objects are compressedUse git show to display content
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 historyIntermediate tagsBranch pointsRelative points
Git referencesReferences: “labels” for Git SHA-1 commit IDsStored as files under .git/refsReference types:TagsHeads (branches)HEAD is a special ref:always points tohead of currentbranch.
How Git commits graph looks like ?ReferenceCommitTreePicture courtesyofProGit.org
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 
Real-life Git branchesThink I’m exaggerating ? Look at this example (it’s real, swear !)
Let’s practice on Git branches !
Wear “life jacket” firstGet Git bash extensions source git/contrib/completion/git-completion.bashRedefine promptexport PS1='$(__git_ps1 " (%s)")  ’... and your current branch is visible on your prompt: you will not get lost 
Creating branchesCreate branch  create a new ref to current commit
Switching branchUse git checkout to switch branchCurrent displayed branch changed to experimentalNote that HEAD points to experimental
Commit on branchAdd a new commit to experimental branchSee the new branch graph (gitk)
MergeWhen experiments are completed … merge back !Checkout masterMerge experimental
Git graph after mergeLet’s have a look on the result with gitkMerge-type applied: Fast-forward (move refs in history)Branch has been “flattened”Experimental just another ref to master
Git recursive-mergeLet’s create some divergenceChanges on both master and experimentalFast-forward merge = move branch ref to another commit ID
Git diverging branchesUse gitk --all to display all branchesNOTE: no args displays just current branchexperimental is really diverging from master
Git recursive mergeLet’s merge again with masterThis 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 
Merge alternatives: rebasePicture courtesyofProGit.org
Git rebase in actionLet’s diverge again between master and experimentalMagic ! … rebase flattens the branching history
Git graph after rebaseExperimental is no more a diverging branchNOTE: Marconi’s test is on “unnamed branch” and experimental branch history has changed !
Merge alternatives: squashoriginC1C2C3C4C5C6C1C2C3C4C3C4C3’+C4’myworkoriginmywork
Git squash in actionGet branch changes but do not join themgit merge –squash experimentalcommit
Git branch graph after squashBranches are still divergingGet all the branch changes in a single commit(squash changes together)
Merge alternatives: cherry-pickoriginC1C2C3C4C5C6C1C2C3C4C5C6C6’myworkoriginmywork
Merge alternatives: cherry-pickGet individual commit IDsApply individual changes to another branch
Git branch graph after cherry-pickIndividual commit has been copied from tesla-testBoth branches are kept
Too easy ?… let’s create some conflict !
Merge conflictSame file changed, same range, two different branches
Resolving conflictGet list of conflicts with git statusDisplay and edit conflicted file
Completing mergeAdd edited file to stageCommit and finalise the merged commit… wasn’t that scary isn’t it ? 
Rebase / cherry-pick conflictSame file changed, same range, two different branches
Don’t panic … unnamed branchCheck in which branch you areCheck files in conflict
Resolve conflict and continue rebaseResolve conflictsContinue rebase
Got lost with commands, merge and conflicts ?
Merge recap
Reverting changes
Git is powerful and dangerousGit has full control on historyAmend existing commitsRemove commitsRevert changesBe careful: you could destroy your history !Be even more careful: history revert is unrecoverableSCARY !!!!!
Change existing commitsGit commit support the “amend” option to overwrite committed dataWhat can be amendedFile changes Author / commentDateThe original commit will disappear: amend is NOT revertible (but just amended again)
Amend last commitLet’s display the last commit on master
Amend last commitLet’s change commit content
Git reset: back to the pastGit reset allows to:Put committed data back to the working dir  soft resetRemove completely committed data  hard resetGit reset is NOT revertibleYou want to reset ?Do you really need it ?Do you really want it ?What do you want to achieve ?… and then think again …
Soft resetRemove the last commit and put changes back to workdirHint:master~1 = reference to “one commit before master head”Commit is lost, but you still have the changes in workdir
Hard resetRemove commit and all the changes associatedCommit is lostFOREVER: there is no way to restore the data
Git revertGit revert allows to:Revert the changes and to workdirRevert the changes and create a “reverted commit”Git revert is revertibleRevert = negative commit (eliminates effect of reverted commit)
Display last commitLet’s display the last commit changes on master
Create reverted commitLet’s revert last commit
Now: how to revert the revert ?Reverted commit is a commitUse reset to eliminate the revert operation
Working with Tags
Importance of Git tagsWhy 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 tagsLightweight tags (simple Git ref to a commit ID)Annotated tags (author, description, signature)
Lightweight tagsLet’s create a lightweight tag… that’s easier to remember than b7dbbe69f0be…. !
Fully annotate tagsFully annotated tags contains meta-data:TimestampAuthor name and e-mailDescriptionCommit IDGPG Digital SignatureCreate your private GPG Key-pair firstGPG Public Key identify your userGPG Private Key is used to sign content (tags, commits)Exchange GPG Public Key with your peers
Create GPG Key pair
Create annotated tagLet’s create a fully annotated and signed tagTags are just Git references
Git remote management
Git nature: peer-to-peer distributedGit designed to be distributedGlobal unique IDs for files and commits (SHA-1)Completely disconnected operationsRich set of merging capabilitiesCompression and integrity checkNatural way of using it is peer-to-peer… the Linus way, yeah
Remote Git repositoriesPoints to other’s people repositoryRemote Git servers / locationRemote Git branchesExample: clone GIT source code repository via “remote”git clone git://git.kernel.org/pub/scm/git/git.git
Inspecting remote pointersList of remote Git repositoriesName “origin” refers to remote Git repositoryList of remote Git branches
Push changes to remote Git repositoryAdd pointer to remote Git repositoryPush all local branches to remote Git repository
Getting remote Git repository updatesFetching remote changes with git fetchMerge (or rebase) changes
Getting changes: shortcutsUse git pull for merging with remote changesgit pull = git fetch + git merge… beaware of the branches merge mess !Use git fetch + git rebase with a macro: git updateupdate = !sh -c 'git stash clear && git stash && git fetch origin && git rebase origin/master && git stash pop’git update = git fetch + git rebase… flat and clean history … seems like SVN isn’t it ? 
Git repositories (local/remote) recap
Choosing your Git Server
Public Git Server: githubMany choices … but github is the best !Create your SSH Key-pairssh-keygen -trsa -b 2048Create your free acount on: https://github.com/signup/freeCreate your repository on:https://github.com/repositories/newAdd your remotegit remote add origin git@github.com:lucamilanesio/33degree.git
Private Git Server: GitEnterpriseMany 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 2048Create your free acount on: https://gitent-scm.com/gitent/users/SignUp.gitCreate your repository on:https://gitent-scm.com/gitent/repository/RepositoryCreation.gitAdd your remotegit remote add origin ssh://lmilanesio@gitent-scm.com/git/gitentdevelopment/33degree
3rd choice: make your own !Installed on your network, running on your hardwareNOTE: make daily backups … GIT is dangerous !Gitosis (http://eagain.net/gitweb/?p=gitosis.git)Users / Groups / KeysRepository managementEverything managed with Git Management Repository Gerrit (http://code.google.com/p/gerrit/)Full Web-based InterfaceUsers / Groups integrated with LDAP, OpenID, …Full repository and security managementFull code-review lifecycle management
Git collaboration: anarchy
Everybody fetch/pull from each otherAnnaJohnCathyLinusLukePeterNobody pushes: everybody fetch or pullEvery Git repository has the same importance
How does it work ?Run your own Git server with git daemonOthers can clone and fetch from your repositoryYou see them fetching
Git collaboration: dictator and lieutenants
Developers fetch/pull, dictator pushesgit pushDevelopers pull, Lieutenants integrateDictator get integration branches together: he is the only one that PUSH to GitPicture courtesyofProGit.org
GitHub variantgit pushDevelopers pull from “blessed” and have their own public GitIntegration manager is the DictatorRevolution allowed: developer nominates himself “new dictator”Picture courtesyofProGit.org
Git Democracy
Unique central repositoryEverybody can push / pull from shared Git RepositoryCentral repository dies  elections of new repositoryPicture courtesyofProGit.org
Back to centralisation ? WTF ?Does it seems like SVN ? … much more guys Git Democracy vs. SVNHorizontal collaboration between developers (P2P)Continuous branching / merging“promotions” of changes through voting (Gerrit model)Control over integration / releaseDoes it seems like Git is mature for the Enterprise ?

More Related Content

Git workshop 33degree 2011 krakow

  • 1. GitLuca MilanesioAndroid programmingSang ShinThe Productive ProgrammerNeal FordThe Power of RetrospectionLinda RisingIntroduction to ScalaHubert PlociniczakMain sponsor
  • 2. AgendaSCM and Git ConceptsGit quick startBranching and mergingResolving conflictsReverting changesWorking with tagsGit remotesGit on the serverGit peer-to-peerGit democracy
  • 3. Who’s that guy ?Luca MilanesioLMIT Limited – Director / co-founder of GitEnterprise.comJenkins (formerly Hudson) contributor since 2007founder of hudson-mobi.comOver 18 years of experience in Software and Services Development and Application LifecycleWorked for major UK, EU and US CustomersBanking, Retailers, Industry, Finance, Telecoms, Utilities, GovernmentGit enthusiast since 2009 and innovator in Vodafone Group Services Ltd
  • 4. About SCM … remember ?SCM = Source Code ManagementMultiple revisions of files
  • 8. Manage branches of development
  • 9. Integrate the work of multiple teams together
  • 10. … and much more Picture courtesyofglobalnerdy.com - Allrightskindlyreserved
  • 11. Brief history of OpenSourceSCMsLocal SCMs (versions kept on local filesystem)SCCS (1972) … I was not yet born, don’t remember RCS (1982) the most widely used on UnixServer-based SCMs (central repository server)CVS (1990) first widely used SCM serverSubversion (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 SCMUnique “source of truth”Central back-upSeamless alignment for all developersSecurity and access controlDistributed SCMCommunity code-baseNo single-point-of-failurePeer-to-peer alignmentContinuous 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: BitKeeperApr 2005 – Linus writes PERL scripts for Linux Kernel SCMJul 2005 … Git 0.99 is out !Git principles:Allow the BitKeeper SCM workflowUse CVS as the “not-to-do” exampleCheck and prevent corruptionMake it FFF … FAST FAST FAST !
  • 15. BORED of too much theory ?
  • 17. Git installation (Ver. >=1.6)Linux (Gitfavourite of course !)Ubuntu: sudo apt-get install git-coreother Linux ? … best from source codehttp://git-scm.com/Mac OSXhttp://code.google.com/p/git-osx-installer/Windowshttp://code.google.com/p/msysgit/(sucks … but it’s your fault not using Unix)CygwinHIGHLY RECOMMENDED (mandatory IMHO)
  • 18. Step 1 – Git repositorycreate project
  • 20. $ git initStep 2 – Git identityDefine your full name
  • 22. Everything stored in .git/configStep 3 – Add some files and commitCreate some files
  • 23. Add to GIT (default = recursive)
  • 24. CommitStep 4 – Inspect GIT logGet GIT history of commits
  • 25. Display changesToo simple ? … let’s add some statesThree states of Git files1. Unstaged2. Staged3. Cleangit addgit commitPicture courtesyofProGit.org
  • 26. State 1. unstagedCreate a new fileChange an existing fileCheck status
  • 27. State 2. stagedAdd the two files to staging areaCheck status
  • 28. State 3. work directory cleanCommit the staging areaCheck status
  • 29. Display Git lifecycleAdd another file and make some changes$ gitgui
  • 30. Stage with gitguiSelect files and chose “Stage to commit”
  • 31. Commit with gitguiEnter commit message and click “commit”
  • 32. Git graph log with gitk
  • 34. Git stores the whole fileGit is different from SVN: no diffs, just whole filesGit stores changed files between snapshots(BitKeeperdocet)Picture courtesyofProGit.org
  • 35. Git object types: blobsGit stores all files (and their versions) as objects (blobs)Each object has a SHA-1 160-bit identifierSHA-1 provides:Unique Global IDIntegrity checkExample: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 globallySHA-1 collision probability is 1/251What 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 treesGit tree identifies a snapshot (set of files)Git commit identifiesAuthor / CommitterCommit messageTimestampTreePicture courtesyofProGit.org
  • 38. Git history: graph of commitsEvery commit points to its predecessorSeries of commits make Git repository historyPicture courtesyofProGit.org
  • 39. Where are Git objects ?Git objects are in .git/objectsSHA-1 identify directory / file
  • 40. Curious about Git objects ?Git objects are compressedUse 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 historyIntermediate tagsBranch pointsRelative points
  • 42. Git referencesReferences: “labels” for Git SHA-1 commit IDsStored as files under .git/refsReference types:TagsHeads (branches)HEAD is a special ref:always points tohead of currentbranch.
  • 43. How Git commits graph looks like ?ReferenceCommitTreePicture 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 branchesThink I’m exaggerating ? Look at this example (it’s real, swear !)
  • 46. Let’s practice on Git branches !
  • 47. Wear “life jacket” firstGet Git bash extensions source git/contrib/completion/git-completion.bashRedefine promptexport PS1='$(__git_ps1 " (%s)") ’... and your current branch is visible on your prompt: you will not get lost 
  • 48. Creating branchesCreate branch  create a new ref to current commit
  • 49. Switching branchUse git checkout to switch branchCurrent displayed branch changed to experimentalNote that HEAD points to experimental
  • 50. Commit on branchAdd a new commit to experimental branchSee the new branch graph (gitk)
  • 51. MergeWhen experiments are completed … merge back !Checkout masterMerge experimental
  • 52. Git graph after mergeLet’s have a look on the result with gitkMerge-type applied: Fast-forward (move refs in history)Branch has been “flattened”Experimental just another ref to master
  • 53. Git recursive-mergeLet’s create some divergenceChanges on both master and experimentalFast-forward merge = move branch ref to another commit ID
  • 54. Git diverging branchesUse gitk --all to display all branchesNOTE: no args displays just current branchexperimental is really diverging from master
  • 55. Git recursive mergeLet’s merge again with masterThis 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 
  • 56. Merge alternatives: rebasePicture courtesyofProGit.org
  • 57. Git rebase in actionLet’s diverge again between master and experimentalMagic ! … rebase flattens the branching history
  • 58. Git graph after rebaseExperimental is no more a diverging branchNOTE: Marconi’s test is on “unnamed branch” and experimental branch history has changed !
  • 60. Git squash in actionGet branch changes but do not join themgit merge –squash experimentalcommit
  • 61. Git branch graph after squashBranches are still divergingGet all the branch changes in a single commit(squash changes together)
  • 63. Merge alternatives: cherry-pickGet individual commit IDsApply individual changes to another branch
  • 64. Git branch graph after cherry-pickIndividual commit has been copied from tesla-testBoth branches are kept
  • 65. Too easy ?… let’s create some conflict !
  • 66. Merge conflictSame file changed, same range, two different branches
  • 67. Resolving conflictGet list of conflicts with git statusDisplay and edit conflicted file
  • 68. Completing mergeAdd edited file to stageCommit and finalise the merged commit… wasn’t that scary isn’t it ? 
  • 69. Rebase / cherry-pick conflictSame file changed, same range, two different branches
  • 70. Don’t panic … unnamed branchCheck in which branch you areCheck files in conflict
  • 71. Resolve conflict and continue rebaseResolve conflictsContinue rebase
  • 72. Got lost with commands, merge and conflicts ?
  • 75. Git is powerful and dangerousGit has full control on historyAmend existing commitsRemove commitsRevert changesBe careful: you could destroy your history !Be even more careful: history revert is unrecoverableSCARY !!!!!
  • 76. Change existing commitsGit commit support the “amend” option to overwrite committed dataWhat can be amendedFile changes Author / commentDateThe original commit will disappear: amend is NOT revertible (but just amended again)
  • 77. Amend last commitLet’s display the last commit on master
  • 78. Amend last commitLet’s change commit content
  • 79. Git reset: back to the pastGit reset allows to:Put committed data back to the working dir  soft resetRemove completely committed data  hard resetGit reset is NOT revertibleYou 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 resetRemove the last commit and put changes back to workdirHint:master~1 = reference to “one commit before master head”Commit is lost, but you still have the changes in workdir
  • 81. Hard resetRemove commit and all the changes associatedCommit is lostFOREVER: there is no way to restore the data
  • 82. Git revertGit revert allows to:Revert the changes and to workdirRevert the changes and create a “reverted commit”Git revert is revertibleRevert = negative commit (eliminates effect of reverted commit)
  • 83. Display last commitLet’s display the last commit changes on master
  • 84. Create reverted commitLet’s revert last commit
  • 85. Now: how to revert the revert ?Reverted commit is a commitUse reset to eliminate the revert operation
  • 87. Importance of Git tagsWhy 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 tagsLightweight tags (simple Git ref to a commit ID)Annotated tags (author, description, signature)
  • 88. Lightweight tagsLet’s create a lightweight tag… that’s easier to remember than b7dbbe69f0be…. !
  • 89. Fully annotate tagsFully annotated tags contains meta-data:TimestampAuthor name and e-mailDescriptionCommit IDGPG Digital SignatureCreate your private GPG Key-pair firstGPG Public Key identify your userGPG Private Key is used to sign content (tags, commits)Exchange GPG Public Key with your peers
  • 91. Create annotated tagLet’s create a fully annotated and signed tagTags are just Git references
  • 93. Git nature: peer-to-peer distributedGit designed to be distributedGlobal unique IDs for files and commits (SHA-1)Completely disconnected operationsRich set of merging capabilitiesCompression and integrity checkNatural way of using it is peer-to-peer… the Linus way, yeah
  • 94. Remote Git repositoriesPoints to other’s people repositoryRemote Git servers / locationRemote Git branchesExample: clone GIT source code repository via “remote”git clone git://git.kernel.org/pub/scm/git/git.git
  • 95. Inspecting remote pointersList of remote Git repositoriesName “origin” refers to remote Git repositoryList of remote Git branches
  • 96. Push changes to remote Git repositoryAdd pointer to remote Git repositoryPush all local branches to remote Git repository
  • 97. Getting remote Git repository updatesFetching remote changes with git fetchMerge (or rebase) changes
  • 98. Getting changes: shortcutsUse git pull for merging with remote changesgit pull = git fetch + git merge… beaware of the branches merge mess !Use git fetch + git rebase with a macro: git updateupdate = !sh -c 'git stash clear && git stash && git fetch origin && git rebase origin/master && git stash pop’git update = git fetch + git rebase… flat and clean history … seems like SVN isn’t it ? 
  • 101. Public Git Server: githubMany choices … but github is the best !Create your SSH Key-pairssh-keygen -trsa -b 2048Create your free acount on: https://github.com/signup/freeCreate your repository on:https://github.com/repositories/newAdd your remotegit remote add origin git@github.com:lucamilanesio/33degree.git
  • 102. Private Git Server: GitEnterpriseMany 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 2048Create your free acount on: https://gitent-scm.com/gitent/users/SignUp.gitCreate your repository on:https://gitent-scm.com/gitent/repository/RepositoryCreation.gitAdd 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 hardwareNOTE: make daily backups … GIT is dangerous !Gitosis (http://eagain.net/gitweb/?p=gitosis.git)Users / Groups / KeysRepository managementEverything managed with Git Management Repository Gerrit (http://code.google.com/p/gerrit/)Full Web-based InterfaceUsers / Groups integrated with LDAP, OpenID, …Full repository and security managementFull code-review lifecycle management
  • 105. Everybody fetch/pull from each otherAnnaJohnCathyLinusLukePeterNobody pushes: everybody fetch or pullEvery Git repository has the same importance
  • 106. How does it work ?Run your own Git server with git daemonOthers can clone and fetch from your repositoryYou see them fetching
  • 107. Git collaboration: dictator and lieutenants
  • 108. Developers fetch/pull, dictator pushesgit pushDevelopers pull, Lieutenants integrateDictator get integration branches together: he is the only one that PUSH to GitPicture courtesyofProGit.org
  • 109. GitHub variantgit pushDevelopers pull from “blessed” and have their own public GitIntegration manager is the DictatorRevolution allowed: developer nominates himself “new dictator”Picture courtesyofProGit.org
  • 111. Unique central repositoryEverybody can push / pull from shared Git RepositoryCentral repository dies  elections of new repositoryPicture courtesyofProGit.org
  • 112. Back to centralisation ? WTF ?Does it seems like SVN ? … much more guys Git Democracy vs. SVNHorizontal collaboration between developers (P2P)Continuous branching / merging“promotions” of changes through voting (Gerrit model)Control over integration / releaseDoes it seems like Git is mature for the Enterprise ?
  • 113. Git branching modelPicture courtesyofProGit.org
  • 114. Working with topic branchesDevelopers work on topicsCode-review / votes promote them to masterTopics branches removed after mergeNOTE: better rebase than mergePicture courtesyofProGit.org
  • 115. Topic branches exampleDeveloper A starts working on topic-1Developer B starts working on topic-2
  • 116. Code-review: merge topic-1Get topic-1 code and code-review on integration branchEverything’s fine: commit the merge and remove topic-1
  • 117. Code-review: merge topic-2Repeat the same with topic-2
  • 118. Release manager: merge integrationRelease manager decides about releasing integration branchNOTE: No conflicts are generated  all merges are from integration branch
  • 119. Further reading and referencesFurther readingProGit: http://progit.org/
  • 120. Git cheat sheets: http://help.github.com/git-cheat-sheets/Git Services:github: http://github.com
  • 121. GitEnterprise: http://gitenterprise.comThank you for your patience,You resisted 3h … YEAH !
  • 122. BOF: Hack your companyJakub NabrdalikBOF: Web framework shootoutBłażej Bucko, Tomasz Dziurko, Wojciech Erbetowski, Łukasz Kuczera, Paweł SzulcBOF: Future of Java EEAlexis Moussine-PouchkineBOF: Those broken, broken class loadersJevgeniKabanovMain sponsor