SlideShare una empresa de Scribd logo
1 de 34
Descargar para leer sin conexión
OptionFactory
Git, beyond the basics
intermediate level workshop
About OptionFactory
Main activities
● Software development & consultancy
● Continuous Integration & Delivery
● Training & coaching
Key competences
● Java, Javascript, C++, Go, Erlang and more
● Secure Software Development Lifecycle
● Lean Software Development
● Re-engineering
Core domains
● High Availability and High Performance systems
● Application security
● Telcos, finance, insurance and security sensitive domains
● Startups, new markets and high uncertainty domains
Goals
If that doesn’t fix it, git.txt
contains the phone number of a
friend of mine who understands
git. Just wait through a few
minutes of “It’s really pretty
simple, just think of branches
as…” and eventually you’ll learn
the commands that will fix
everything.
HTTP://XKCD.COM/1597/
“
Goals (II)
No, improvising is wonderful.
But, the thing is that you cannot
improvise unless you know
exactly what you're doing.
Christopher Walken
“
”
Establishing a common base
● Participants’
○ background
○ VCS tools known
○ level of experience
○ expectations
Version control in 4 steps
● Do some work
● Checkin a “unit of work” (aka: transaction). Think “savegame”
● Repeat as much as you want
● Go back “in time” when something happens. Think “reload and try again”
Version control landscape
Git Mercurial (HG) SVN ClearCase
Model Distributed (clone) Distributed (clone) Centralized
(checkout)
Centralized
(checkout)
Transaction unit Commit Commit Commit File
Storage model Snapshot Delta Delta ?
Transaction id Hash Hash (local
sequence)
Global sequence Path + per-branch
sequence
Concurrency
model
Merge/Rebase
(graph)
Merge (graph) Merge on commit
(linear)
Pessimistic
locking + merge
(linear)
Rename / move
tracking
No (heuristic) Yes Yes Yes*
Centralized vs distributed (I)
Centralized vs Distributed (II)
Centralized Distributed
Instances Single, mandatory
Every istance is equal. “Central authority” is a
convention, not a necessity
Transaction id Centrally assigned Anyone must be able to assign it
The Truth™ One and only
“Luke, you're going to find that many of the truths we cling
to depend greatly on our own point of view.” _ Obi-Wan
Kenobi
Centralized vs Distributed (III)
Centralized Distributed
Isolation None, each transaction is “public” Many Sandboxes environments
Speed per
commit
Low, every transaction required
network communication
Fast, changes are on the local filesystem.
Conflicts Pain Manageable pain
Version control landscape
Git Mercurial (HG) SVN ClearCase
Model Distributed (clone) Distributed (clone) Centralized
(checkout)
Centralized
(checkout)
Transaction unit Commit Commit Commit File
Storage model Snapshot Delta Delta ?
Transaction id Hash Hash (local
sequence)
Global sequence Path + per-branch
sequence
Concurrency
model
Merge/Rebase
(graph)
Merge (graph) Merge on commit
(linear)
Pessimistic
locking + merge
(linear)
Rename / move
tracking
No (heuristic) Yes Yes Yes*
Delta storage
Snapshot storage
Starting up
● setup your global git environment
git config --global user.name “Mario Rossi”
git config --global user.email “mrossi@example.com”
● initialize (i.e. create) your first repository
mkdir myfirstrepo
cd myfirstrepo
git init
Inside a commit
● parent id(s)
● timestamp
● author (& committer)
● content
○ filesystem state
NOT part of a commit (more on that later)
● branch
● tags
Creating a commit
● Create / edit files on your working copy (your local filesystem)
● Mark your changes for inclusion by copying them in the staging area
● Create a new commit, providing the missing (meta) data
● What goes in the commit comes from:
○ whatever you put in the staging area
○ your global git configuration (e.g. your name, email)
○ the git environment (e.g. the current date, the commit you started working from)
○ the commit message you specify
Files lifecycle
checkout/reset (file)
Checkout <file> Checkout <ref> -- <file> Reset <file>
Effect on graph
shape
None None None
Effect on
Staging Area
None Overwritten with version from graph Overwritten with version from
graph
Effect on
working copy
Overwrite with version from
staging area
Overwritten with version from graph None
Staging area
Working Copy Graph
add <file> com
m
it
reset<file>
checkout <ref> -- <file>
checkout <file>
Alternate (time)lines
● Creating alternate lines of work
○ branch
● Navigating the graph
○ checkout
○ reset
● “Crossing the streams” and other weird stuff
○ merging
○ rebasing
○ cherry-picking
References & reachability
● A reference is just a named pointer to a commit in the graph
● Every commit, to be reachable, must be referenced:
○ directly (by a ref)
○ indirectly (by a reachable descendant, pointing to its parent)
● Bad parenting advisory:
○ Parent commits do not know about their children
○ You can’t navigate forward in time through the graph
references: Branches
● a “branch” identifies a sequence of commits, tracing a workflow
● “master” is by convention the project main line
● A branch points to a commit in the graph, and represents a pointer to such
commit. It is not directly related to working copy or staging area
● Any number of branches can point to the same commit, they are all
independent
references: HEAD
● HEAD is a special reference. It can either point to a commit or a branch,
and represents where we are in the graph
● The commit it points to (directly or indirectly) is used for comparison
against the staging area
● When HEAD points to a Branch reference, that branch is “current”, and will
move ahead on commit
● When HEAD points directly to a commit, we are in the “detached HEAD”
state
○ this is true even if there are branches referencing that same commit
references: Tags
● Lightweight Tags are similar to branches (a name attached to a specific
commit), but they are not meant to move
● Annotated Tags also contain an id, timestamp, author and a message on
top of that
● Therefore, annotated tags can be signed
Checkout/Reset/Revert (ref)
Checkout <ref> Reset <ref> Revert <ref>
Moves HEAD only “current” Branch “current” Branch
Effect on graph shape None potentially leaves back “dead”
nodes
Creates new node
Effect on Staging Area Fails if dirty* overwritten with --mixed (default)
or --hard
Fails if dirty
Effect on working
Copy
Fails if dirty overwritten only with --hard Attempts merge, fail if
not possible
Remotes, refs, tracking branches
● remotes: names pointer to a remote repository
○ origin is the one you cloned from (just another convention)
● remote branches
○ Remote references differ from branches (refs/heads references) mainly in that they’re
considered read-only. You can git checkout to one, but Git won’t point HEAD at one, so
you’ll never update it with a commit command. Git manages them as bookmarks to the last
known state of where those branches were on those servers.
● tracking branches
○ created once you checkout a remote branch
○ tracks your work on that branch to allow sync
Synchronization & collaboration
● clone
● push
● fetch
● pull (fetch+merge o fetch+rebase)
Collaborative workflow
● commit message
● approach
○ merge-based
○ rebase-based
○ not exclusive
http://zeroturnaround.com/wp-content/uploads/2016/02/Git-Cheat-Sheet.png
Version control landscape
Git Mercurial (HG) SVN ClearCase
Model Distributed (clone) Distributed (clone) Centralized
(checkout)
Centralized
(checkout)
Transaction unit Commit Commit Commit File
Storage model Snapshot Delta Delta ?
Transaction id Hash Hash (local
sequence)
Global sequence Path + per-branch
sequence
Concurrency
model
Merge/Rebase
(graph)
Merge (graph) Merge on commit
(linear)
Pessimistic
locking + merge
(linear)
Rename / move
tracking
No (heuristic) Yes Yes Yes*
git as a service
● github, gitlab, bitbucket
● basic concepts mapping
● Authorization models
● “Fork” and “Pull Request” implementations
○ pull request
■ What’s that? “Please, take my changes”
security and workflow considerations
● Certificates
● Credentials storage
Plumbing
Resources
■ Good base: http://www.learnenough.com/git-tutorial
■ Visualizing Git Concepts with D3: https://onlywei.github.io/explain-git-with-d3/
■ Think like a git: http://think-like-a-git.net/epic.html
■ Cache your passwords: https://help.github.com/articles/caching-your-github-password-in-git/
■ Git-csm book, in particular:
● https://git-scm.com/book/en/v2/Git-Basics-Recording-Changes-to-the-Repository
● https://git-scm.com/book/en/v2/Git-Tools-Reset-Demystified
● https://git-scm.com/book/en/v2/Git-Basics-Git-Aliases
■ Some open source projects to visualize git graphs:
● https://github.com/FredrikNoren/ungit/blob/master/README.md
● https://github.com/Readify/GitViz
● https://github.com/Haacked/SeeGit
■ Always funny to watch: http://gource.io/
■ Git cheat sheet: http://zeroturnaround.com/rebellabs/git-commands-and-best-practices-cheat-sheet/
■ Interesting videos:
● Git For Ages 4 And Up: https://www.youtube.com/watch?v=1ffBJ4sVUb4
● Introduction to Git with Scott Chacon of GitHub: https://www.youtube.com/watch?v=ZDR433b0HJY

Más contenido relacionado

Similar a Git Intermediate Workshop slides v1.3

Similar a Git Intermediate Workshop slides v1.3 (20)

Git of every day
Git of every dayGit of every day
Git of every day
 
devops-complete-notes-2.pdf
devops-complete-notes-2.pdfdevops-complete-notes-2.pdf
devops-complete-notes-2.pdf
 
Git_new.pptx
Git_new.pptxGit_new.pptx
Git_new.pptx
 
Command line git
Command line gitCommand line git
Command line git
 
Embedded Systems: Lecture 12: Introduction to Git & GitHub (Part 3)
Embedded Systems: Lecture 12: Introduction to Git & GitHub (Part 3)Embedded Systems: Lecture 12: Introduction to Git & GitHub (Part 3)
Embedded Systems: Lecture 12: Introduction to Git & GitHub (Part 3)
 
Introduction to Git and GitHub
Introduction to Git and GitHubIntroduction to Git and GitHub
Introduction to Git and GitHub
 
Introduction to Git for developers
Introduction to Git for developersIntroduction to Git for developers
Introduction to Git for developers
 
Git usage (Basics and workflow)
Git usage (Basics and workflow)Git usage (Basics and workflow)
Git usage (Basics and workflow)
 
Git 101 for Beginners
Git 101 for Beginners Git 101 for Beginners
Git 101 for Beginners
 
Git 101: Force-sensitive to Jedi padawan
Git 101: Force-sensitive to Jedi padawanGit 101: Force-sensitive to Jedi padawan
Git 101: Force-sensitive to Jedi padawan
 
Roslyn on GitHub
Roslyn on GitHubRoslyn on GitHub
Roslyn on GitHub
 
Git uptospeed
Git uptospeedGit uptospeed
Git uptospeed
 
An intro to git
An intro to gitAn intro to git
An intro to git
 
Git and git hub
Git and git hubGit and git hub
Git and git hub
 
Git vs Subversion: ¿Cuando elegir uno u otro?
Git vs Subversion: ¿Cuando elegir uno u otro?Git vs Subversion: ¿Cuando elegir uno u otro?
Git vs Subversion: ¿Cuando elegir uno u otro?
 
Git in a nutshell
Git in a nutshellGit in a nutshell
Git in a nutshell
 
Getting Git
Getting GitGetting Git
Getting Git
 
Git basics with notes
Git basics with notesGit basics with notes
Git basics with notes
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Git
 
Embracing Distributed Version Control
Embracing Distributed Version ControlEmbracing Distributed Version Control
Embracing Distributed Version Control
 

Último

call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️anilsa9823
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceanilsa9823
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 

Último (20)

call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 

Git Intermediate Workshop slides v1.3

  • 1. OptionFactory Git, beyond the basics intermediate level workshop
  • 2. About OptionFactory Main activities ● Software development & consultancy ● Continuous Integration & Delivery ● Training & coaching Key competences ● Java, Javascript, C++, Go, Erlang and more ● Secure Software Development Lifecycle ● Lean Software Development ● Re-engineering Core domains ● High Availability and High Performance systems ● Application security ● Telcos, finance, insurance and security sensitive domains ● Startups, new markets and high uncertainty domains
  • 3. Goals If that doesn’t fix it, git.txt contains the phone number of a friend of mine who understands git. Just wait through a few minutes of “It’s really pretty simple, just think of branches as…” and eventually you’ll learn the commands that will fix everything. HTTP://XKCD.COM/1597/ “
  • 4. Goals (II) No, improvising is wonderful. But, the thing is that you cannot improvise unless you know exactly what you're doing. Christopher Walken “ ”
  • 5. Establishing a common base ● Participants’ ○ background ○ VCS tools known ○ level of experience ○ expectations
  • 6. Version control in 4 steps ● Do some work ● Checkin a “unit of work” (aka: transaction). Think “savegame” ● Repeat as much as you want ● Go back “in time” when something happens. Think “reload and try again”
  • 7. Version control landscape Git Mercurial (HG) SVN ClearCase Model Distributed (clone) Distributed (clone) Centralized (checkout) Centralized (checkout) Transaction unit Commit Commit Commit File Storage model Snapshot Delta Delta ? Transaction id Hash Hash (local sequence) Global sequence Path + per-branch sequence Concurrency model Merge/Rebase (graph) Merge (graph) Merge on commit (linear) Pessimistic locking + merge (linear) Rename / move tracking No (heuristic) Yes Yes Yes*
  • 9. Centralized vs Distributed (II) Centralized Distributed Instances Single, mandatory Every istance is equal. “Central authority” is a convention, not a necessity Transaction id Centrally assigned Anyone must be able to assign it The Truth™ One and only “Luke, you're going to find that many of the truths we cling to depend greatly on our own point of view.” _ Obi-Wan Kenobi
  • 10. Centralized vs Distributed (III) Centralized Distributed Isolation None, each transaction is “public” Many Sandboxes environments Speed per commit Low, every transaction required network communication Fast, changes are on the local filesystem. Conflicts Pain Manageable pain
  • 11. Version control landscape Git Mercurial (HG) SVN ClearCase Model Distributed (clone) Distributed (clone) Centralized (checkout) Centralized (checkout) Transaction unit Commit Commit Commit File Storage model Snapshot Delta Delta ? Transaction id Hash Hash (local sequence) Global sequence Path + per-branch sequence Concurrency model Merge/Rebase (graph) Merge (graph) Merge on commit (linear) Pessimistic locking + merge (linear) Rename / move tracking No (heuristic) Yes Yes Yes*
  • 14. Starting up ● setup your global git environment git config --global user.name “Mario Rossi” git config --global user.email “mrossi@example.com” ● initialize (i.e. create) your first repository mkdir myfirstrepo cd myfirstrepo git init
  • 15. Inside a commit ● parent id(s) ● timestamp ● author (& committer) ● content ○ filesystem state NOT part of a commit (more on that later) ● branch ● tags
  • 16. Creating a commit ● Create / edit files on your working copy (your local filesystem) ● Mark your changes for inclusion by copying them in the staging area ● Create a new commit, providing the missing (meta) data ● What goes in the commit comes from: ○ whatever you put in the staging area ○ your global git configuration (e.g. your name, email) ○ the git environment (e.g. the current date, the commit you started working from) ○ the commit message you specify
  • 18. checkout/reset (file) Checkout <file> Checkout <ref> -- <file> Reset <file> Effect on graph shape None None None Effect on Staging Area None Overwritten with version from graph Overwritten with version from graph Effect on working copy Overwrite with version from staging area Overwritten with version from graph None Staging area Working Copy Graph add <file> com m it reset<file> checkout <ref> -- <file> checkout <file>
  • 19. Alternate (time)lines ● Creating alternate lines of work ○ branch ● Navigating the graph ○ checkout ○ reset ● “Crossing the streams” and other weird stuff ○ merging ○ rebasing ○ cherry-picking
  • 20. References & reachability ● A reference is just a named pointer to a commit in the graph ● Every commit, to be reachable, must be referenced: ○ directly (by a ref) ○ indirectly (by a reachable descendant, pointing to its parent) ● Bad parenting advisory: ○ Parent commits do not know about their children ○ You can’t navigate forward in time through the graph
  • 21. references: Branches ● a “branch” identifies a sequence of commits, tracing a workflow ● “master” is by convention the project main line ● A branch points to a commit in the graph, and represents a pointer to such commit. It is not directly related to working copy or staging area ● Any number of branches can point to the same commit, they are all independent
  • 22. references: HEAD ● HEAD is a special reference. It can either point to a commit or a branch, and represents where we are in the graph ● The commit it points to (directly or indirectly) is used for comparison against the staging area ● When HEAD points to a Branch reference, that branch is “current”, and will move ahead on commit ● When HEAD points directly to a commit, we are in the “detached HEAD” state ○ this is true even if there are branches referencing that same commit
  • 23. references: Tags ● Lightweight Tags are similar to branches (a name attached to a specific commit), but they are not meant to move ● Annotated Tags also contain an id, timestamp, author and a message on top of that ● Therefore, annotated tags can be signed
  • 24. Checkout/Reset/Revert (ref) Checkout <ref> Reset <ref> Revert <ref> Moves HEAD only “current” Branch “current” Branch Effect on graph shape None potentially leaves back “dead” nodes Creates new node Effect on Staging Area Fails if dirty* overwritten with --mixed (default) or --hard Fails if dirty Effect on working Copy Fails if dirty overwritten only with --hard Attempts merge, fail if not possible
  • 25. Remotes, refs, tracking branches ● remotes: names pointer to a remote repository ○ origin is the one you cloned from (just another convention) ● remote branches ○ Remote references differ from branches (refs/heads references) mainly in that they’re considered read-only. You can git checkout to one, but Git won’t point HEAD at one, so you’ll never update it with a commit command. Git manages them as bookmarks to the last known state of where those branches were on those servers. ● tracking branches ○ created once you checkout a remote branch ○ tracks your work on that branch to allow sync
  • 26. Synchronization & collaboration ● clone ● push ● fetch ● pull (fetch+merge o fetch+rebase)
  • 27. Collaborative workflow ● commit message ● approach ○ merge-based ○ rebase-based ○ not exclusive
  • 29. Version control landscape Git Mercurial (HG) SVN ClearCase Model Distributed (clone) Distributed (clone) Centralized (checkout) Centralized (checkout) Transaction unit Commit Commit Commit File Storage model Snapshot Delta Delta ? Transaction id Hash Hash (local sequence) Global sequence Path + per-branch sequence Concurrency model Merge/Rebase (graph) Merge (graph) Merge on commit (linear) Pessimistic locking + merge (linear) Rename / move tracking No (heuristic) Yes Yes Yes*
  • 30. git as a service ● github, gitlab, bitbucket ● basic concepts mapping ● Authorization models ● “Fork” and “Pull Request” implementations ○ pull request ■ What’s that? “Please, take my changes”
  • 31. security and workflow considerations ● Certificates ● Credentials storage
  • 32.
  • 34. Resources ■ Good base: http://www.learnenough.com/git-tutorial ■ Visualizing Git Concepts with D3: https://onlywei.github.io/explain-git-with-d3/ ■ Think like a git: http://think-like-a-git.net/epic.html ■ Cache your passwords: https://help.github.com/articles/caching-your-github-password-in-git/ ■ Git-csm book, in particular: ● https://git-scm.com/book/en/v2/Git-Basics-Recording-Changes-to-the-Repository ● https://git-scm.com/book/en/v2/Git-Tools-Reset-Demystified ● https://git-scm.com/book/en/v2/Git-Basics-Git-Aliases ■ Some open source projects to visualize git graphs: ● https://github.com/FredrikNoren/ungit/blob/master/README.md ● https://github.com/Readify/GitViz ● https://github.com/Haacked/SeeGit ■ Always funny to watch: http://gource.io/ ■ Git cheat sheet: http://zeroturnaround.com/rebellabs/git-commands-and-best-practices-cheat-sheet/ ■ Interesting videos: ● Git For Ages 4 And Up: https://www.youtube.com/watch?v=1ffBJ4sVUb4 ● Introduction to Git with Scott Chacon of GitHub: https://www.youtube.com/watch?v=ZDR433b0HJY