git - introduction and overview
DESCRIPTION
Quick Git overview presented at a Rackspace Tech Night - it is not a tutorial, no previous knowledge is required, we are simply looking to introduce the concepts of version control and cover some good practice steps when dealing with repositories.TRANSCRIPT
![Page 1: Git - Introduction and Overview](https://reader036.vdocuments.us/reader036/viewer/2022081718/54c7dabd4a79598a3f8b458d/html5/thumbnails/1.jpg)
Adnan Smajlovic
Big Cloud Solutions – DevOps Advisory
GitIntroduction and Overview
![Page 2: Git - Introduction and Overview](https://reader036.vdocuments.us/reader036/viewer/2022081718/54c7dabd4a79598a3f8b458d/html5/thumbnails/2.jpg)
2RACKSPACE® HOSTING | WWW.RACKSPACE.COM
•Git repositories are not linear– Branching already supported
•Branches are trees of trees•Visualise
– The state of your repository as a point in a high-dimensional ‘code-space’
– Branches are represented as n-dimensional membranes
– Map the spatial loci of successive commits onto the projected manifold of each cloned repository
The Simple Stuff
![Page 3: Git - Introduction and Overview](https://reader036.vdocuments.us/reader036/viewer/2022081718/54c7dabd4a79598a3f8b458d/html5/thumbnails/3.jpg)
3RACKSPACE® HOSTING | WWW.RACKSPACE.COM
![Page 4: Git - Introduction and Overview](https://reader036.vdocuments.us/reader036/viewer/2022081718/54c7dabd4a79598a3f8b458d/html5/thumbnails/4.jpg)
4RACKSPACE® HOSTING | WWW.RACKSPACE.COM
•Git satire– A Guide to Git using spatial analogies
• http://tartley.com/?p=1267• “Tartley, you’re one sick puppy”
Just Kidding
![Page 5: Git - Introduction and Overview](https://reader036.vdocuments.us/reader036/viewer/2022081718/54c7dabd4a79598a3f8b458d/html5/thumbnails/5.jpg)
5RACKSPACE® HOSTING | WWW.RACKSPACE.COM
•Scope•Background•Features•Services
– Github– GitLab– Bitbucket
•Resources•Q&A
Agenda
![Page 6: Git - Introduction and Overview](https://reader036.vdocuments.us/reader036/viewer/2022081718/54c7dabd4a79598a3f8b458d/html5/thumbnails/6.jpg)
RACKSPACE® HOSTING | WWW.RACKSPACE.COM
Scope
![Page 7: Git - Introduction and Overview](https://reader036.vdocuments.us/reader036/viewer/2022081718/54c7dabd4a79598a3f8b458d/html5/thumbnails/7.jpg)
7RACKSPACE® HOSTING | WWW.RACKSPACE.COM
•Purpose– Introduce distributed version control concept– Generate some Git interest
• Depending on use will lead to:– awe
– fear
– hate
– suffering
• Pass on the stories, don’t be ‘that’ guy
– Some useful concepts• Branch, merge, rebase, amend
Scope
![Page 8: Git - Introduction and Overview](https://reader036.vdocuments.us/reader036/viewer/2022081718/54c7dabd4a79598a3f8b458d/html5/thumbnails/8.jpg)
8RACKSPACE® HOSTING | WWW.RACKSPACE.COM
•This is not a…– Git tutorial
• Plenty of resources out there– See ‘Resources’ section
• Service providers and projects vary
• That said…– If there is enough interest
• Perhaps a fully-fledged ‘enabler’ tech night• “Dude, what the hell is Jenkins and how do I integrate Git with it?”
• What is this Selenium and SauceLabs business about?”
Scope
![Page 9: Git - Introduction and Overview](https://reader036.vdocuments.us/reader036/viewer/2022081718/54c7dabd4a79598a3f8b458d/html5/thumbnails/9.jpg)
9RACKSPACE® HOSTING | WWW.RACKSPACE.COM
•This is not a…– GitHub tutorial
• There are alternatives
Scope
![Page 10: Git - Introduction and Overview](https://reader036.vdocuments.us/reader036/viewer/2022081718/54c7dabd4a79598a3f8b458d/html5/thumbnails/10.jpg)
RACKSPACE® HOSTING | WWW.RACKSPACE.COM
Background
![Page 11: Git - Introduction and Overview](https://reader036.vdocuments.us/reader036/viewer/2022081718/54c7dabd4a79598a3f8b458d/html5/thumbnails/11.jpg)
11RACKSPACE® HOSTING | WWW.RACKSPACE.COM
•Record changes to resources– Not limited to software code
• e.g. Wiki article versioning
•Recall specific versions– Revert to previous state
• File• Image• Project
•Tracking– Revision numbers (e.g. 1.0.1, r3893, etc.)
Version Control - What
![Page 12: Git - Introduction and Overview](https://reader036.vdocuments.us/reader036/viewer/2022081718/54c7dabd4a79598a3f8b458d/html5/thumbnails/12.jpg)
12RACKSPACE® HOSTING | WWW.RACKSPACE.COM
•Local– Copy to another directory– Patching mechanism
• Recovery based on revision sets• “It’s so simple” (!)
– What if?• Forget where it is stored• Overwrite wrong file• Database is corrupted• Datacentre blows up
Version Control - How
![Page 13: Git - Introduction and Overview](https://reader036.vdocuments.us/reader036/viewer/2022081718/54c7dabd4a79598a3f8b458d/html5/thumbnails/13.jpg)
13RACKSPACE® HOSTING | WWW.RACKSPACE.COM
•Centralised– Collaborator count > 1– Client-server model– Due diligence
• Auditing capabilities
– Access control– What if?
• Network connection has high latency• Server fails• Datacentre blows up
Version Control - How
![Page 14: Git - Introduction and Overview](https://reader036.vdocuments.us/reader036/viewer/2022081718/54c7dabd4a79598a3f8b458d/html5/thumbnails/14.jpg)
14RACKSPACE® HOSTING | WWW.RACKSPACE.COM
•Distributed– Full mirror
• Clients can restore content to server• Every copy is a backup
– Hierarchy options• Cross-system collaboration
– What if?• Attempt to break it• Datacentre blo…oh, wait
Version Control - How
![Page 15: Git - Introduction and Overview](https://reader036.vdocuments.us/reader036/viewer/2022081718/54c7dabd4a79598a3f8b458d/html5/thumbnails/15.jpg)
15RACKSPACE® HOSTING | WWW.RACKSPACE.COM
Version Control - Who
![Page 16: Git - Introduction and Overview](https://reader036.vdocuments.us/reader036/viewer/2022081718/54c7dabd4a79598a3f8b458d/html5/thumbnails/16.jpg)
16RACKSPACE® HOSTING | WWW.RACKSPACE.COM
•Linux kernel developers abandoned BitKeeper– BitMover alleges reverse-engineering of protocols– Withdraws free use
•Linus Torvalds sets out to write one– Existing systems do not meet requirements
•Emphasis on speed– Patch the Linux kernel tree at a set rate
•Avoid conventional approaches– Do the opposite of what CVS did– Name it ‘git’ – Torvalds refers to himself as one (!)
Birth of Git
![Page 17: Git - Introduction and Overview](https://reader036.vdocuments.us/reader036/viewer/2022081718/54c7dabd4a79598a3f8b458d/html5/thumbnails/17.jpg)
RACKSPACE® HOSTING | WWW.RACKSPACE.COM
Features
![Page 18: Git - Introduction and Overview](https://reader036.vdocuments.us/reader036/viewer/2022081718/54c7dabd4a79598a3f8b458d/html5/thumbnails/18.jpg)
18RACKSPACE® HOSTING | WWW.RACKSPACE.COM
![Page 19: Git - Introduction and Overview](https://reader036.vdocuments.us/reader036/viewer/2022081718/54c7dabd4a79598a3f8b458d/html5/thumbnails/19.jpg)
19RACKSPACE® HOSTING | WWW.RACKSPACE.COM
•Distributed Version Control System (DVCS)– Fast version control– Cheap local branching– Easy to learn
•Arguable – some experience required to leverage the more useful features
– Influenced by BitKeeper and Monotone concepts
•Source Code Management (SCM) principles– Change identification via ‘revision number’
• Keep an eye out for those alphanumeric strings…
Git Features
![Page 20: Git - Introduction and Overview](https://reader036.vdocuments.us/reader036/viewer/2022081718/54c7dabd4a79598a3f8b458d/html5/thumbnails/20.jpg)
20RACKSPACE® HOSTING | WWW.RACKSPACE.COM
•Some goals– Fast
• Must handle patching of the Linux kernel source/tree
– Fully distributed• In case the datacentre blows up
– Simple design• Compatibility with existing systems and protocols
– Strong non-linear development orientation• Rapid branching and merging• Thousands of parallel branches
Git Features
![Page 21: Git - Introduction and Overview](https://reader036.vdocuments.us/reader036/viewer/2022081718/54c7dabd4a79598a3f8b458d/html5/thumbnails/21.jpg)
21RACKSPACE® HOSTING | WWW.RACKSPACE.COM
•Snapshots
Git Features
![Page 22: Git - Introduction and Overview](https://reader036.vdocuments.us/reader036/viewer/2022081718/54c7dabd4a79598a3f8b458d/html5/thumbnails/22.jpg)
22RACKSPACE® HOSTING | WWW.RACKSPACE.COM
• “Think locally not globally (!)”– Most operations require local files/resources only
• Integrity– Checksum all the things
• Generally only add data (apologies to Bruce Lee)– Almost everything has an undo action
• The Three States– Committed– Modified– Staged
Git Features
![Page 23: Git - Introduction and Overview](https://reader036.vdocuments.us/reader036/viewer/2022081718/54c7dabd4a79598a3f8b458d/html5/thumbnails/23.jpg)
23RACKSPACE® HOSTING | WWW.RACKSPACE.COM
![Page 24: Git - Introduction and Overview](https://reader036.vdocuments.us/reader036/viewer/2022081718/54c7dabd4a79598a3f8b458d/html5/thumbnails/24.jpg)
24RACKSPACE® HOSTING | WWW.RACKSPACE.COM
•Diverge and fix (or break) stuff•Main line of development unaffected•Cheap to use branches
– Writing 41 bytes to a file– Old school methods used to copy everything :-/
•Basic merge process– Identify best common ancestor– Three-way merge (new snapshot)– Merged work in a new commit object
Good to Know - Branch
![Page 25: Git - Introduction and Overview](https://reader036.vdocuments.us/reader036/viewer/2022081718/54c7dabd4a79598a3f8b458d/html5/thumbnails/25.jpg)
25RACKSPACE® HOSTING | WWW.RACKSPACE.COM
Good to Know - Branch
![Page 26: Git - Introduction and Overview](https://reader036.vdocuments.us/reader036/viewer/2022081718/54c7dabd4a79598a3f8b458d/html5/thumbnails/26.jpg)
26RACKSPACE® HOSTING | WWW.RACKSPACE.COM
Good to Know - Branch
![Page 27: Git - Introduction and Overview](https://reader036.vdocuments.us/reader036/viewer/2022081718/54c7dabd4a79598a3f8b458d/html5/thumbnails/27.jpg)
27RACKSPACE® HOSTING | WWW.RACKSPACE.COM
Good to Know - Branch
![Page 28: Git - Introduction and Overview](https://reader036.vdocuments.us/reader036/viewer/2022081718/54c7dabd4a79598a3f8b458d/html5/thumbnails/28.jpg)
28RACKSPACE® HOSTING | WWW.RACKSPACE.COM
Good to Know - Branch
![Page 29: Git - Introduction and Overview](https://reader036.vdocuments.us/reader036/viewer/2022081718/54c7dabd4a79598a3f8b458d/html5/thumbnails/29.jpg)
29RACKSPACE® HOSTING | WWW.RACKSPACE.COM
•Things do not always go smoothly•Merge a branch with the master
– Same object changed in multiple branches– Attempt to merge leads to conflict– ‘git status’ shows the list of unmerged objects– Conflicts are marked
•Pick the one you want
Good to Know - Conflicts
![Page 30: Git - Introduction and Overview](https://reader036.vdocuments.us/reader036/viewer/2022081718/54c7dabd4a79598a3f8b458d/html5/thumbnails/30.jpg)
30RACKSPACE® HOSTING | WWW.RACKSPACE.COM
<<<<<<< HEAD:somefile.extGo away!=======Please go away!>>>>>>> mybranch:somefile.ext
Good to Know - Conflicts
![Page 31: Git - Introduction and Overview](https://reader036.vdocuments.us/reader036/viewer/2022081718/54c7dabd4a79598a3f8b458d/html5/thumbnails/31.jpg)
31RACKSPACE® HOSTING | WWW.RACKSPACE.COM
•Effectively – patching•Process
– Grab a diff of each commit– Store in temp files– Reset current branch as rebase target– Apply changes in turn
•Just one rule to remember– “Do not rebase commits that you have pushed to a
public repository”
Good to Know - Rebase
![Page 32: Git - Introduction and Overview](https://reader036.vdocuments.us/reader036/viewer/2022081718/54c7dabd4a79598a3f8b458d/html5/thumbnails/32.jpg)
32RACKSPACE® HOSTING | WWW.RACKSPACE.COM
Good to Know - Rebase
![Page 33: Git - Introduction and Overview](https://reader036.vdocuments.us/reader036/viewer/2022081718/54c7dabd4a79598a3f8b458d/html5/thumbnails/33.jpg)
33RACKSPACE® HOSTING | WWW.RACKSPACE.COM
Good to Know - Rebase
![Page 34: Git - Introduction and Overview](https://reader036.vdocuments.us/reader036/viewer/2022081718/54c7dabd4a79598a3f8b458d/html5/thumbnails/34.jpg)
34RACKSPACE® HOSTING | WWW.RACKSPACE.COM
Good to Know - Rebase
![Page 35: Git - Introduction and Overview](https://reader036.vdocuments.us/reader036/viewer/2022081718/54c7dabd4a79598a3f8b458d/html5/thumbnails/35.jpg)
35RACKSPACE® HOSTING | WWW.RACKSPACE.COM
•Rewrite history every once in a while• “Dude, I don’t want to look like an idiot”• ‘git commit --amend’
– Change the commit message– Add or remove objects
•This is a mini-rebase– Keep the perils of rebasing in mind
Good to Know - Amend
![Page 36: Git - Introduction and Overview](https://reader036.vdocuments.us/reader036/viewer/2022081718/54c7dabd4a79598a3f8b458d/html5/thumbnails/36.jpg)
36RACKSPACE® HOSTING | WWW.RACKSPACE.COM
•Fork a repo•Track changes in parent repo (‘git remote’)
– Commits can be quickly pulled back into the fork
•Create a branch in the fork (‘git branch)– Keeps the forked repo clean (see previous point)
•Modify branch and push back (‘git push’)•Test your changes
– Generally recommended unless you take rejection well
•Pull request to parent repo from your branch
Good Practice
![Page 37: Git - Introduction and Overview](https://reader036.vdocuments.us/reader036/viewer/2022081718/54c7dabd4a79598a3f8b458d/html5/thumbnails/37.jpg)
RACKSPACE® HOSTING | WWW.RACKSPACE.COM
Services
![Page 38: Git - Introduction and Overview](https://reader036.vdocuments.us/reader036/viewer/2022081718/54c7dabd4a79598a3f8b458d/html5/thumbnails/38.jpg)
38RACKSPACE® HOSTING | WWW.RACKSPACE.COM
•May be referred to as “Git as a Service”•Generally public and private repositories•May offer multiple SCM offerings•Additional services
– Code review– Issue tracking– Wiki
GaaS for the Masses
![Page 39: Git - Introduction and Overview](https://reader036.vdocuments.us/reader036/viewer/2022081718/54c7dabd4a79598a3f8b458d/html5/thumbnails/39.jpg)
39RACKSPACE® HOSTING | WWW.RACKSPACE.COM
•Most popular source code repo site– Social networking concepts
•Public and private repos•Free (well…)
– Up to a point– No private repos for the free plan
•Enterprise offering available– Bring GitHub to your own servers– Rackspace makes use of it– Not exactly cheap (!)
GitHub
![Page 40: Git - Introduction and Overview](https://reader036.vdocuments.us/reader036/viewer/2022081718/54c7dabd4a79598a3f8b458d/html5/thumbnails/40.jpg)
40RACKSPACE® HOSTING | WWW.RACKSPACE.COM
•Source code in GitHub o_0•Free (kind of…)
– Self-hosted – you still need a server to run it on
•GitLab Cloud– Hosted GitLab– Unlimited private repos (10 users)
•GitLab CI– Almost-native CI service
GitLab
![Page 41: Git - Introduction and Overview](https://reader036.vdocuments.us/reader036/viewer/2022081718/54c7dabd4a79598a3f8b458d/html5/thumbnails/41.jpg)
41RACKSPACE® HOSTING | WWW.RACKSPACE.COM
•Free (almost…)– Up to 5 users
•Unlimited private repos•Offers Mercurial support
– Start-up that was acquired– Atlassian introduced Git support in 2011
•Enterprise offering available– Cheaper than GitHub (at the time of writing)
• “Built for JIRA”– Stick a #resolve in your commit message
Bitbucket
![Page 42: Git - Introduction and Overview](https://reader036.vdocuments.us/reader036/viewer/2022081718/54c7dabd4a79598a3f8b458d/html5/thumbnails/42.jpg)
RACKSPACE® HOSTING | WWW.RACKSPACE.COM
Resources
![Page 43: Git - Introduction and Overview](https://reader036.vdocuments.us/reader036/viewer/2022081718/54c7dabd4a79598a3f8b458d/html5/thumbnails/43.jpg)
43RACKSPACE® HOSTING | WWW.RACKSPACE.COM
•The Git SCM book– From the horses mouth– Thank you for the images used in this deck– http://git-scm.com/book
•Vogella Git Tutorial– Lars Vogel– http://vogella.com/articles/Git/
•Git for computer scientists– If you’re all about pointers–http://eagain.net/articles/git-for-computer-scientists/
Resources
![Page 44: Git - Introduction and Overview](https://reader036.vdocuments.us/reader036/viewer/2022081718/54c7dabd4a79598a3f8b458d/html5/thumbnails/44.jpg)
44RACKSPACE® HOSTING | WWW.RACKSPACE.COM
•The Git SCM tutorial– http://git-scm.com/docs/gittutorial
•Six Revisions tutorials–http://sixrevisions.com/resources/git-tutorials-beginners/
•Code School tutorial– Try Git– http://try.github.io/
Resources
![Page 45: Git - Introduction and Overview](https://reader036.vdocuments.us/reader036/viewer/2022081718/54c7dabd4a79598a3f8b458d/html5/thumbnails/45.jpg)
RACKSPACE® HOSTING | WWW.RACKSPACE.COM
Questions?
![Page 46: Git - Introduction and Overview](https://reader036.vdocuments.us/reader036/viewer/2022081718/54c7dabd4a79598a3f8b458d/html5/thumbnails/46.jpg)
46RACKSPACE® HOSTING | © RACKSPACE US, INC. | RACKSPACE® AND FANATICAL SUPPORT® ARE SERVICE MARKS OF RACKSPACE US, INC. REGISTERED IN THE UNITED STATES AND OTHER COUNTRIES. | WWW.RACKSPACE.CO.UK
RACKSPACE® HOSTING | 5 MILLINGTON ROAD | HAYES, UNITED KINGDOM UB3 4AZ
UK SALES: +44 (0)20 8712 6507 | UK SUPPORT: 0800 988 0300 | WWW.RACKSPACE.CO.UK