Post on 18-Jan-2016
Page 1TBD
www.groupe-sii.com
12/08/2014
FormationGIT
Laurent Kappel
Groupe SII 65, rue de Bercy - 75012 ParisTél : 01 42 84 82 22 - Fax : 01 42 84 30 82
Page 2TBD
Sommaire
12/08/2014
Git is Fast
GIT is DistributedGIT is SCM
Git is ReliableUsing Git
Git is AgileGit Re-Writing History
Git Workflow
Page 3TBD
GIT is SCM
« branch »
« merge »
Page 4TBD
Panorama des SCM
Page 5TBD
A little about history …
Page 6TBD
Git is not an evolution
Page 7TBD
Who is using Git
Page 8TBD
GIT is Distributed
DistributedFast
Reliable
Page 9TBD
Centralized SCM
Single Pointof Failure
Network(slow)
AccessRights?
Page 10TBD
Git is Distributed
No a priori structure
But Git ≠ Anarchy
Page 11TBD
Git is Distributed
A very common practice:Sharing via user-owned repos
READONLY
RD/WR
Page 12TBD
Git is Distributed
A very common practice:Sharing via user-owned repos
Git Hosting: https://git.wiki.kernel.org/index.php/GitHosting:
Page 13TBD
Git is Distributed
Hosted
Page 14TBD
Distributed Workflow Example
Integration-Manager
Dictator & Lieutenants
Page 15TBD
Distributed Workflow Example
Other developersonly READ
Only Danmay WRITE
NewRelease
develop, commit
ShareFeatures
IntegrateFeatures
Page 16TBD
Distributed Workflow Example
Integration-Manager
Dictator & Lieutenants
Page 17TBD
Distributed Workflow Example
Page 18TBD
GIT Avantages
DistributedFast
Reliable
Page 19TBD
GIT is Fast
100% local
Page 20TBD
GIT is Fast
Page 21TBD
GIT is Fast
Page 22TBD
GIT is Fast
Page 23TBD
GIT is Fast
Page 24TBD
GIT is Fast
Page 25TBD
GIT is Fast
Page 26TBD
GIT is Fast
Page 27TBD
GIT is Fast
Page 28TBD
GIT is Fast
Page 29TBD
GIT is Fast
Page 30TBD
GIT is Fast
Page 31TBD
GIT is Fast
Page 32TBD
Git Object Database
Page 33TBD
Git Object Database
Page 34TBD
Git Object Database
Page 35TBD
Git Object Database
Page 36TBD
Git Object Database
Page 37TBD
Git Object Database
Page 38TBD
Git Object Database
Page 39TBD
Git Object Database
Page 40TBD
Git Object Database
Page 41TBD
Git Object Database
Page 42TBD
Git Object Database
Page 43TBD
Git Object Database
Page 44TBD
Git Object Database
Page 45TBD
Git Object Database
Page 46TBD
Git Object Database
Page 47TBD
Git Object Database
Page 48TBD
Git Object Database
Page 49TBD
Git Object Database
$ git cat-file -p 8e8eb67tree 91dc8d579f123918f3ac43af1e9377a97128763bauthor Laurent Kappel <lkappel@free.fr> 1407751282 +0200committer Laurent Kappel <lkappel@free.fr> 1407751282 +0200
Mon premier commit
Page 50TBD
Git Object Database
Page 51TBD
Git Object Database
$ git tag -a v2.0 -m 'my version 2.0'$ cat .git/refs/tags/v2.0
Page 52TBD
Git Object Database
Page 53TBD
This makes Git Fast
• Restore an arbitrary version– Git: checkout a hash = O(1)– SVN: diffs between n last commits = O(n)
• Compare 2 revisions• Reset• Search through history• And many more…
Page 54TBD
Some Benchmarking
http://git-scm.com/about/small-and-fast
Page 55TBD
Git is Reliable
DistributedFast
Reliable
Page 56TBD
Git is Reliable
1. Because it’s Distributed Single dev with a remote? => 2 copies (local, remote) .git/ has it all
2. Checksums (SHA-1) for all objects Git uses Detects data corruption Guarantees Authenticity
Page 57TBD
Using Git
Page 58TBD
Using Git
$ git clone https://github.com/tpaskap/gitdoc.gitCloning into ‘gitdoc'...remote: Counting objects: 67870, done.remote: Compressing objects: 100% (13454/13454), done.remote: Total 67870 (delta 49179), reused 67358 (delta 48872)Receiving objects: 100% (67870/67870), 51.40 MiB | 5.15 MiB/s, done.Resolving deltas: 100% (49179/49179), done.
$ cd gitdoc$ ls –a
... ppt .git .gitignore LICENSE README
Local Repo Working Directory
Page 59TBD
Using Git
$ git remote –vorigin https://github.com/tpaskap/GITDOC.git (fetch)origin https://github.comt/paskap/GITDOC.git (push)
$ git branch* master
$ git branch -a* master remotes/origin/HEAD -> origin/master remotes/origin/master
$ git log -n 3 --oneline424a7b2 Merge pull request #202 from g-oikonomou/cc2538-minor-fixes704309c Change the InfoPage Location of the IEEE address8b5b2bd CC2538 Documentation typo and grammar fixes
Page 60TBD
Using Git
Page 61TBD
Using Git
Page 62TBD
Using Git
Page 63TBD
Using Git
Page 64TBD
Using Git
Modificationof tracked contentModificationof tracked content
New, untracked contentNew, untracked content
Page 65TBD
Using Git
Page 66TBD
Using Git
Content of thenext commit
Content of thenext commit
Page 67TBD
Using Git
Page 68TBD
Using Git
Page 69TBD
Using Git
Page 70TBD
Using Git
Page 71TBD
Using Git
Page 72TBD
Using Git
Page 73TBD
Using Git
Merges are done LOCALLY!
“Git push failed, To prevent fromlosing history, non-fast forward
updates were rejected”
Not an error, but common-sense Files are rarely decorrelated
Page 74TBD
Using Git
Page 75TBD
Using Git
Page 76TBD
Using Git
Page 77TBD
Using Git
Still not permittedGit is happyBut how can PROJECT authors trust you?
Page 78TBD
Using Git
$ git remote add cetic git@github.com:login/GITDOC.git
Page 79TBD
Using Git
$ git remote add cetic git@github.com:lkappel/GITDOC.git
git push cetic master
OK
alias du remote
nom utilisateur
Page 80TBD
Using Git
$ git remote add cetic git@github.com:lkappel/GITDOC.git
$ git push cetic master
OK New repo = 2 commands !
Remote Repo$ git push [remote] [branch]$ git push [remote] [branch[:alias]]
alias remote branch
Page 81TBD
Using Git
Page 82TBD
Using Git
Page 83TBD
Using Git
Page 84TBD
Using Git
Jan Krüger’s Cheat Sheethttp://jan-krueger.net/git
Page 85TBD
Using Git
Git LOVES branches, and so should you
Page 86TBD
Git is Agile
Page 87TBD
Git is Agile
Page 88TBD
Git is Agile
Page 89TBD
Git is Agile
Page 90TBD
Git is Agile
Page 91TBD
Git is Agile
Page 92TBD
Git is Agile
Page 93TBD
Git is Agile
Page 94TBD
Git is Agile
Page 95TBD
Git is Agile
Page 96TBD
Re-Writing History
Page 97TBD
Re-Writing History
Page 98TBD
Re-Writing History
git rebase –i 8b5b2bd
Page 99TBD
Re-Writing History
Page 100TBD
Re-Writing History
Page 101TBD
Re-Writing History
Page 102TBD
Re-Writing History
Page 103TBD
Re-Writing History
Page 104TBD
Cherry-Picking
Page 105TBD
Cherry-Picking
Page 106TBD
Cherry-Picking
Page 107TBD
Others commands
Page 108TBD
Workflow
– How to structure a repository• Branches and their interactions• How the project moves forward
– Organizing people• Who accesses what• How are contributions merged? Where? By who?• Responsibilities
Working together with Git « Workflow » ?
Page 109TBD
GitFlow
http://nvie.com/posts/a-successful-git-branching-model/
Page 110TBD
GitFlow
Page 111TBD
GitFlow
Page 112TBD
GitFlow
Page 113TBD
GitFlow
Page 114TBD
GitFlow
Page 115TBD
GitFlow
https://github.com/nvie/gitflow
Page 116TBD
Workflow
– How to structure a repository• Branches and their interactions• How the project moves forward
– Organizing people• Who accesses what• How are contributions merged? Where? By who?• Responsibilities
Working together with Git « Workflow » ?
Page 117TBD
Integration Manager Workflow
Page 118TBD
Dictator & Lieutenants Workflow
Page 119TBD
Getting Started with Git
• Book: Pro Git. http://www.git-scm.com
• Selected Tutorials:– Git Immersion http://gitimmersion.com/
– Learn Git Branching workflow : http://nvie.com/posts/a-successful-git-branching-model/interactive : http://pcottle.github.io/learnGitBranching/
• More material:– https://training.github.com/
Page 120TBD
The End
Questions ?
Thanks !