Download - Geecon11 - Git: a Gentle InTroduction
![Page 2: Geecon11 - Git: a Gentle InTroduction](https://reader034.vdocuments.us/reader034/viewer/2022050614/5870e0381a28abcf288b488b/html5/thumbnails/2.jpg)
Agenda
About version controlConceptsWorking locally
Remote operations
Enterprise adoptionQ&A
![Page 3: Geecon11 - Git: a Gentle InTroduction](https://reader034.vdocuments.us/reader034/viewer/2022050614/5870e0381a28abcf288b488b/html5/thumbnails/3.jpg)
Hey dude who are ya??
Developer since 1988XP Coach during 2kCo-founder and coordinator of JUG Torino
Java Champion since 2005
Manager at Gitenterprise.comWorking as contractor across Europe
![Page 4: Geecon11 - Git: a Gentle InTroduction](https://reader034.vdocuments.us/reader034/viewer/2022050614/5870e0381a28abcf288b488b/html5/thumbnails/4.jpg)
About version control
P icture courtesy of globalnerdy.comAll rights kindly reserved
![Page 5: Geecon11 - Git: a Gentle InTroduction](https://reader034.vdocuments.us/reader034/viewer/2022050614/5870e0381a28abcf288b488b/html5/thumbnails/5.jpg)
Centralized SCM
CVSSVN
P icture courtesy of progit.org. All rights kindly reserved
![Page 6: Geecon11 - Git: a Gentle InTroduction](https://reader034.vdocuments.us/reader034/viewer/2022050614/5870e0381a28abcf288b488b/html5/thumbnails/6.jpg)
Distributed SCM
Git
MercurialBazaar
P icture courtesy of progit.org. All rights kindly reserved
![Page 7: Geecon11 - Git: a Gentle InTroduction](https://reader034.vdocuments.us/reader034/viewer/2022050614/5870e0381a28abcf288b488b/html5/thumbnails/7.jpg)
Concepts
![Page 8: Geecon11 - Git: a Gentle InTroduction](https://reader034.vdocuments.us/reader034/viewer/2022050614/5870e0381a28abcf288b488b/html5/thumbnails/8.jpg)
Concepts
Snapshots, not deltas
Nearly every operation is localIntegrity is a priority
The “three states”
![Page 9: Geecon11 - Git: a Gentle InTroduction](https://reader034.vdocuments.us/reader034/viewer/2022050614/5870e0381a28abcf288b488b/html5/thumbnails/9.jpg)
Snapshot, not deltas
Deltas are maintained: CVS, SVN, Bazaar
P icture courtesy of progit.org. All rights kindly reserved
![Page 10: Geecon11 - Git: a Gentle InTroduction](https://reader034.vdocuments.us/reader034/viewer/2022050614/5870e0381a28abcf288b488b/html5/thumbnails/10.jpg)
Snapshot, not deltas
Full file is maintained: Git, BitKeeper
P icture courtesy of progit.org. All rights kindly reserved
![Page 11: Geecon11 - Git: a Gentle InTroduction](https://reader034.vdocuments.us/reader034/viewer/2022050614/5870e0381a28abcf288b488b/html5/thumbnails/11.jpg)
Most operations are local
Your local database contains a full copy of the remote(s)Browsing, changing, search happens locallyAlmost everything doable without network
the db is a nice, separate .git folder :)
![Page 12: Geecon11 - Git: a Gentle InTroduction](https://reader034.vdocuments.us/reader034/viewer/2022050614/5870e0381a28abcf288b488b/html5/thumbnails/12.jpg)
Integrity is a priority
Everything in Git is check-summedSHA-1 hash
40-character string such as 95b87297210672b16bb70ded20626c9c551ccd58
It's impossible to make a change without Git knowing it!
Git generally only adds data
![Page 13: Geecon11 - Git: a Gentle InTroduction](https://reader034.vdocuments.us/reader034/viewer/2022050614/5870e0381a28abcf288b488b/html5/thumbnails/13.jpg)
The thre e s tate s
modified
stagedcommitted
all local operations!
P icture courtesy of progit.org. All rights kindly reserved
![Page 14: Geecon11 - Git: a Gentle InTroduction](https://reader034.vdocuments.us/reader034/viewer/2022050614/5870e0381a28abcf288b488b/html5/thumbnails/14.jpg)
Quick demo!
Configuration Initializing a local
repositoryManaging files
Looking into history
![Page 15: Geecon11 - Git: a Gentle InTroduction](https://reader034.vdocuments.us/reader034/viewer/2022050614/5870e0381a28abcf288b488b/html5/thumbnails/15.jpg)
Local operations
![Page 16: Geecon11 - Git: a Gentle InTroduction](https://reader034.vdocuments.us/reader034/viewer/2022050614/5870e0381a28abcf288b488b/html5/thumbnails/16.jpg)
How does it work
Git has an internal object database
It containsblob (files)
commit tree
…and other stuff :)
![Page 17: Geecon11 - Git: a Gentle InTroduction](https://reader034.vdocuments.us/reader034/viewer/2022050614/5870e0381a28abcf288b488b/html5/thumbnails/17.jpg)
After a commit...
P icture courtesy of progit.org. All rights kindly reserved
![Page 18: Geecon11 - Git: a Gentle InTroduction](https://reader034.vdocuments.us/reader034/viewer/2022050614/5870e0381a28abcf288b488b/html5/thumbnails/18.jpg)
After three commits...
P icture courtesy of progit.org. All rights kindly reserved
![Page 19: Geecon11 - Git: a Gentle InTroduction](https://reader034.vdocuments.us/reader034/viewer/2022050614/5870e0381a28abcf288b488b/html5/thumbnails/19.jpg)
A branch is a pointer
P icture courtesy of progit.org. All rights kindly reserved
![Page 20: Geecon11 - Git: a Gentle InTroduction](https://reader034.vdocuments.us/reader034/viewer/2022050614/5870e0381a28abcf288b488b/html5/thumbnails/20.jpg)
Creating a branch
> git branch testing
P icture courtesy of progit.org. All rights kindly reserved
![Page 21: Geecon11 - Git: a Gentle InTroduction](https://reader034.vdocuments.us/reader034/viewer/2022050614/5870e0381a28abcf288b488b/html5/thumbnails/21.jpg)
HEAD
HEAD: a special pointer so Git knows where you are
P icture courtesy of progit.org. All rights kindly reserved
![Page 22: Geecon11 - Git: a Gentle InTroduction](https://reader034.vdocuments.us/reader034/viewer/2022050614/5870e0381a28abcf288b488b/html5/thumbnails/22.jpg)
Switching to a branch
Git moves HEAD pointerto the branch pointer
> git checkout testingSwitched to branch 'testing'
P icture courtesy of progit.org. All rights kindly reserved
![Page 23: Geecon11 - Git: a Gentle InTroduction](https://reader034.vdocuments.us/reader034/viewer/2022050614/5870e0381a28abcf288b488b/html5/thumbnails/23.jpg)
Change a file (on a branch)
Git keeps following with HEAD the branch pointer
> vi readme.txt> git commit -a -m 'readme file updated'
P icture courtesy of progit.org. All rights kindly reserved
![Page 24: Geecon11 - Git: a Gentle InTroduction](https://reader034.vdocuments.us/reader034/viewer/2022050614/5870e0381a28abcf288b488b/html5/thumbnails/24.jpg)
Switch to master
Git moves back HEAD to point to master
> git checkout master
P icture courtesy of progit.org. All rights kindly reserved
![Page 25: Geecon11 - Git: a Gentle InTroduction](https://reader034.vdocuments.us/reader034/viewer/2022050614/5870e0381a28abcf288b488b/html5/thumbnails/25.jpg)
And change again!> vi readme.txt> git commit -a -m 'readme file now rocks!'
Git still keeping separatepointers to the branches
P icture courtesy of progit.org. All rights kindly reserved
![Page 26: Geecon11 - Git: a Gentle InTroduction](https://reader034.vdocuments.us/reader034/viewer/2022050614/5870e0381a28abcf288b488b/html5/thumbnails/26.jpg)
Time to merge!
A new “merge” commit is generated
> git merge testingMerge made by recursive. 1 files changed, 1 instions(+), 0 dltions(-)
P icture courtesy of progit.org. All rights kindly reserved
![Page 27: Geecon11 - Git: a Gentle InTroduction](https://reader034.vdocuments.us/reader034/viewer/2022050614/5870e0381a28abcf288b488b/html5/thumbnails/27.jpg)
Remote operations
![Page 28: Geecon11 - Git: a Gentle InTroduction](https://reader034.vdocuments.us/reader034/viewer/2022050614/5870e0381a28abcf288b488b/html5/thumbnails/28.jpg)
What's a remote?
You can have multiple remote reposusually one, “origin”
sometimes one main r/w, other r/o,rarely multiple
Collaborating means pushing and pulling data from the remote repos
![Page 29: Geecon11 - Git: a Gentle InTroduction](https://reader034.vdocuments.us/reader034/viewer/2022050614/5870e0381a28abcf288b488b/html5/thumbnails/29.jpg)
Using a remote: clone
Move into an empty folder...
Different protocols are availablegit (native)http(s)ssh
You get a full copy of the repository
> git clone <url>
![Page 30: Geecon11 - Git: a Gentle InTroduction](https://reader034.vdocuments.us/reader034/viewer/2022050614/5870e0381a28abcf288b488b/html5/thumbnails/30.jpg)
(less usual) Add a remote
Move into an existing git folder...
Mostly used when working with multiple repositories
> git remote add <name> <url>
![Page 31: Geecon11 - Git: a Gentle InTroduction](https://reader034.vdocuments.us/reader034/viewer/2022050614/5870e0381a28abcf288b488b/html5/thumbnails/31.jpg)
Initial clone
P icture courtesy of progit.org. All rights kindly reserved
![Page 32: Geecon11 - Git: a Gentle InTroduction](https://reader034.vdocuments.us/reader034/viewer/2022050614/5870e0381a28abcf288b488b/html5/thumbnails/32.jpg)
How do it syncs?
“master” is tracked automatically“fetch” command will download all the updates from the
remote db“merge” to merge the branches
“rebase” (let's see this later)
“pull” is a shortcut for fetch + merge
![Page 33: Geecon11 - Git: a Gentle InTroduction](https://reader034.vdocuments.us/reader034/viewer/2022050614/5870e0381a28abcf288b488b/html5/thumbnails/33.jpg)
I do some work...
P icture courtesy of progit.org. All rights kindly reserved
![Page 34: Geecon11 - Git: a Gentle InTroduction](https://reader034.vdocuments.us/reader034/viewer/2022050614/5870e0381a28abcf288b488b/html5/thumbnails/34.jpg)
Someone else pushes!
P icture courtesy of progit.org. All rights kindly reserved
![Page 35: Geecon11 - Git: a Gentle InTroduction](https://reader034.vdocuments.us/reader034/viewer/2022050614/5870e0381a28abcf288b488b/html5/thumbnails/35.jpg)
Synchronize with fetch
P icture courtesy of progit.org. All rights kindly reserved
![Page 36: Geecon11 - Git: a Gentle InTroduction](https://reader034.vdocuments.us/reader034/viewer/2022050614/5870e0381a28abcf288b488b/html5/thumbnails/36.jpg)
What next?
Fetch is just fetching all the data, nothing changesTo update your master copy to the remote you may:
Merge
Rebase
You can have done a pull (fetch + merge)
![Page 37: Geecon11 - Git: a Gentle InTroduction](https://reader034.vdocuments.us/reader034/viewer/2022050614/5870e0381a28abcf288b488b/html5/thumbnails/37.jpg)
Merge!
Git uses an automatic three-ways merge algorithm very efficient :)
Most of the time it's a piece of cakeAny conflict not resolved automarically must be
resolved... by you (as usual!)
![Page 38: Geecon11 - Git: a Gentle InTroduction](https://reader034.vdocuments.us/reader034/viewer/2022050614/5870e0381a28abcf288b488b/html5/thumbnails/38.jpg)
Rebase!
First removes from the target branch the diverging commits
Then adds all the changes committed on the source other branch
Then adds your commits on top
![Page 39: Geecon11 - Git: a Gentle InTroduction](https://reader034.vdocuments.us/reader034/viewer/2022050614/5870e0381a28abcf288b488b/html5/thumbnails/39.jpg)
Rebase!
Afte r a
re base ,,,
P icture courtesy of progit.org. All rights kindly reserved
![Page 40: Geecon11 - Git: a Gentle InTroduction](https://reader034.vdocuments.us/reader034/viewer/2022050614/5870e0381a28abcf288b488b/html5/thumbnails/40.jpg)
Rebase!
No differences in resultMuch cleaner historyBranches are then easy to integrate to the master
![Page 41: Geecon11 - Git: a Gentle InTroduction](https://reader034.vdocuments.us/reader034/viewer/2022050614/5870e0381a28abcf288b488b/html5/thumbnails/41.jpg)
Quick demo!
Cloning a repo Fetching from a remoteMerging and rebasing
![Page 42: Geecon11 - Git: a Gentle InTroduction](https://reader034.vdocuments.us/reader034/viewer/2022050614/5870e0381a28abcf288b488b/html5/thumbnails/42.jpg)
Enterprise adoption
![Page 43: Geecon11 - Git: a Gentle InTroduction](https://reader034.vdocuments.us/reader034/viewer/2022050614/5870e0381a28abcf288b488b/html5/thumbnails/43.jpg)
Issues in the enterprise?
No security out of the boxsecure protocols are based on OS services
no way to restrict the access to a repository no way to lock a branchno audit
you can commit in behalf of someone else
![Page 44: Geecon11 - Git: a Gentle InTroduction](https://reader034.vdocuments.us/reader034/viewer/2022050614/5870e0381a28abcf288b488b/html5/thumbnails/44.jpg)
More issues in the enterprise!
No easy setup for users and groupsadministration is a pain (again based on the OS services)Only basic repository visualization (and nothing on the
remote)
![Page 45: Geecon11 - Git: a Gentle InTroduction](https://reader034.vdocuments.us/reader034/viewer/2022050614/5870e0381a28abcf288b488b/html5/thumbnails/45.jpg)
Solutions?
use a predefined solution on top of a *nix environmentgitolite (requires *nix os)gitosis (requires *nix os)
gerrit (not 100% git, but works well)
get an industrialized service/solutiongitenterprise (yeah, the shameless plug, finally!)Github-fi (guess what? now called github enterprise)
…not much more here :)
![Page 46: Geecon11 - Git: a Gentle InTroduction](https://reader034.vdocuments.us/reader034/viewer/2022050614/5870e0381a28abcf288b488b/html5/thumbnails/46.jpg)
Questions?