SlideShare une entreprise Scribd logo
1  sur  45
Télécharger pour lire hors ligne
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 basic idea
● Frequent:
○ Do some work
○ Save and store away a copy of your work at a certain point in time
○ Give each copy a name for future reference
● Once in a while:
○ Be able to go “back in time” to see what changed
○ Possibly discard recent work and start over from a previous point
○ Communicate your changes to others
Analogy: Savegame
Story of a file
● Corso Git Trieste - materiale di presentazione v1.1
Story of a file
● Corso Git Trieste - materiale di presentazione v1.1
● Git Workshop slides v1.2
Story of a file
● Corso Git Trieste - materiale di presentazione v1.1
● Git Workshop slides v1.2
● Git Workshop slides v1.2 - DS
Story of a file
● Corso Git Trieste - materiale di presentazione v1.1
● Git Workshop slides v1.2
● Git Workshop slides v1.2 - DS
● Git Workshop slides v1.2 - RF
Story of a file
● Corso Git Trieste - materiale di presentazione v1.1
● Git Workshop slides v1.2
● Git Workshop slides v1.2 - DS
● Git Workshop slides v1.2 - RF
● Git Workshop slides v1.2 - DS + FD
Story of a file
● Corso Git Trieste - materiale di presentazione v1.1
● Git Workshop slides v1.2
● Git Workshop slides v1.2 - DS
● Git Workshop slides v1.2 - RF
● Git Workshop slides v1.2 - DS + FD
● Git Workshop slides v1.3
Story of a file
● Corso Git Trieste - materiale di presentazione v1.1
● Git Workshop slides v1.2
● Git Workshop slides v1.2 - DS
● Git Workshop slides v1.2 - RF
● Git Workshop slides v1.2 - DS + FD
● Git Workshop slides v1.3
● Git Workshop slides v1.4
Story of a file
● Corso Git Trieste - materiale di presentazione v1.1
● Git Workshop slides v1.2
● Git Workshop slides v1.2 - DS
● Git Workshop slides v1.2 - RF
● Git Workshop slides v1.2 - DS + FD
● Git Workshop slides v1.3
● Git Workshop slides v1.4
Are these all the same file? What’s the sequence?
What we want to capture
Most of the times saving a single file is not enough - information is often
distributed and correlated. In computer programs, changes to one file are often
strongly related to changes in other files - to the point our program breaks down
if we take into account only the changes from one file.
What we are really interested in (each time) is:
● what changed (files)
● where did I start from (previous version)
● who changed it (useful when multiple people collaborate)
● when it changed
● why it changed
● some kind of handle to reference each of such changes
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
Creating a commit
1. Create / edit files on your working copy (your local filesystem)
2. Mark your changes for inclusion by copying them in the staging area
3. Create a new commit, providing the missing (meta) data
● What goes in the commit comes from:
○ whatever you put in the staging area (the “what”)
○ your git configuration:
■ your name & email (the “who”)
○ the (git) environment :
■ the current date (the “when”)
■ the commit you started working from (the “where”)
○ the message you specify (the “why”)
○ the commit itself (commit id, the “handle”)
Delta storage
Snapshot storage
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>
Version control landscape
Git Mercurial (HG) SVN ClearCase
Transaction unit Commit Commit Commit File
Storage model Snapshot Delta Delta ?
Model Distributed (clone) Distributed (clone) Centralized
(checkout)
Centralized
(checkout)
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
The git graph
● Each branch tracks either (or both):
○ alternate “timelines”
○ parallel work
Showing the Git graph
● Some examples:
○ git log --graph --decorate --all --abbrev-commit --pretty=oneline
○ git log --graph --decorate --all --abbrev-commit --format=format:'%C(bold
blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C
(reset)%C(bold yellow)%d%C(reset)%n'' %C(white)%s%C(reset) %C
(dim white)- %an%C(reset)'
● Found a combination you like? keep it as an alias:
○ git config --global alias.graph "log --graph --decorate --all --abbrev-
commit --pretty=oneline"
Showing the Git graph (tools)
Inside a commit
● id
● parent id(s)
● timestamp
● author (& committer)
● message
● content
○ filesystem state
● NOT part of a commit
○ branch
○ tags
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 ref 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
○ even if there are branches referencing that same commit
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
Alternate (time)lines
● Creating alternate lines of work
○ branch
● Navigating the graph
○ checkout
○ reset
● “Crossing the streams” and other weird stuff
○ merging
○ git merge-based <ref> <ref>
○ git config --global merge.conflictstyle diff3 (merge)
○ git merge -Xignore-all-space (-Xignore-space-change)
○ rebasing
○ cherry-picking
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
● 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.
https://git-scm.com/book/it/v2/Git-Internals-Git-References
● tracking branches
○ local branches bound to a remote branch
○ git checkout --track (remote)/(branch)
○ tracks your work on that branch to allow sync
Remotes, refs, tracking branches
Synchronization & collaboration
● clone
● push
● fetch
● pull (fetch+merge o fetch+rebase)
Collaborative workflow
● commit message
● approaches (not exclusive)
○ based on merge
○ based on rebase
http://zeroturnaround.com/wp-content/uploads/2016/02/Git-Cheat-Sheet.png
Version control landscape
Git Mercurial (HG) SVN ClearCase
Transaction unit Commit Commit Commit File
Storage model Snapshot Delta Delta ?
Model Distributed (clone) Distributed (clone) Centralized
(checkout)
Centralized
(checkout)
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*
.gitignore
● Ignores untracked files in the folder or subfolders
● useful to ignore contents generated on the fly, or custom settings files (e.
g.: IDE configuration for the project)
● Useful templates:
○ https://github.com/github/gitignore
○ https://help.github.com/articles/ignoring-files/
git as a service
● github, gitlab, bitbucket
● basic concepts mapping
● Authorization models
● “Fork” and “Pull Request” implementations
○ pull request - “Please, take my changes”
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
■ Git workflows comparison: https://www.atlassian.com/git/tutorials/comparing-workflows
■ Cache your passwords: https://help.github.com/articles/caching-your-github-password-in-git/
■ Git-scm book (https://git-scm.com/book/en/v2), 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/
■ Nice course: http://gitimmersion.com/index.html
■ Nice tool to create demo graphs: http://gitgraphjs.com/
■ Git cheat sheet: http://zeroturnaround.com/rebellabs/git-commands-and-best-practices-cheat-sheet/
■ Interesting videos:
● Introduction to Git with Scott Chacon of GitHub: https://www.youtube.com/watch?v=ZDR433b0HJY
● Brilliant representation of the graph: https://www.youtube.com/watch?v=1ffBJ4sVUb4

Contenu connexe

En vedette

RACF - The Basics (v1.2)
RACF - The Basics (v1.2)RACF - The Basics (v1.2)
RACF - The Basics (v1.2)Rui Miguel Feio
 
Continuous Integration (Jenkins/Hudson)
Continuous Integration (Jenkins/Hudson)Continuous Integration (Jenkins/Hudson)
Continuous Integration (Jenkins/Hudson)Dennys Hsieh
 
Master Data Management
Master Data ManagementMaster Data Management
Master Data ManagementSung Kuan
 
Deep Dive: Amazon Relational Database Service (March 2017)
Deep Dive: Amazon Relational Database Service (March 2017)Deep Dive: Amazon Relational Database Service (March 2017)
Deep Dive: Amazon Relational Database Service (March 2017)Julien SIMON
 
How to identify the correct Master Data subject areas & tooling for your MDM...
How to identify the correct Master Data subject areas & tooling for your MDM...How to identify the correct Master Data subject areas & tooling for your MDM...
How to identify the correct Master Data subject areas & tooling for your MDM...Christopher Bradley
 
10+ Deploys Per Day: Dev and Ops Cooperation at Flickr
10+ Deploys Per Day: Dev and Ops Cooperation at Flickr10+ Deploys Per Day: Dev and Ops Cooperation at Flickr
10+ Deploys Per Day: Dev and Ops Cooperation at FlickrJohn Allspaw
 
MDM Strategy & Roadmap
MDM Strategy & RoadmapMDM Strategy & Roadmap
MDM Strategy & Roadmapvictorlbrown
 

En vedette (8)

RACF - The Basics (v1.2)
RACF - The Basics (v1.2)RACF - The Basics (v1.2)
RACF - The Basics (v1.2)
 
Continuous Integration (Jenkins/Hudson)
Continuous Integration (Jenkins/Hudson)Continuous Integration (Jenkins/Hudson)
Continuous Integration (Jenkins/Hudson)
 
ClearCase Basics
ClearCase BasicsClearCase Basics
ClearCase Basics
 
Master Data Management
Master Data ManagementMaster Data Management
Master Data Management
 
Deep Dive: Amazon Relational Database Service (March 2017)
Deep Dive: Amazon Relational Database Service (March 2017)Deep Dive: Amazon Relational Database Service (March 2017)
Deep Dive: Amazon Relational Database Service (March 2017)
 
How to identify the correct Master Data subject areas & tooling for your MDM...
How to identify the correct Master Data subject areas & tooling for your MDM...How to identify the correct Master Data subject areas & tooling for your MDM...
How to identify the correct Master Data subject areas & tooling for your MDM...
 
10+ Deploys Per Day: Dev and Ops Cooperation at Flickr
10+ Deploys Per Day: Dev and Ops Cooperation at Flickr10+ Deploys Per Day: Dev and Ops Cooperation at Flickr
10+ Deploys Per Day: Dev and Ops Cooperation at Flickr
 
MDM Strategy & Roadmap
MDM Strategy & RoadmapMDM Strategy & Roadmap
MDM Strategy & Roadmap
 

Similaire à Git intermediate workshop slides v1.4

Introduction to Git for developers
Introduction to Git for developersIntroduction to Git for developers
Introduction to Git for developersDmitry Guyvoronsky
 
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 padawanJames Ford
 
BLUG 2012 Version Control for Notes Developers
BLUG 2012 Version Control for Notes DevelopersBLUG 2012 Version Control for Notes Developers
BLUG 2012 Version Control for Notes DevelopersMartin Jinoch
 
Git essential training & sharing self
Git essential training & sharing selfGit essential training & sharing self
Git essential training & sharing selfChen-Tien Tsai
 
Microservices Development Process at Predix.io
Microservices Development Process at Predix.ioMicroservices Development Process at Predix.io
Microservices Development Process at Predix.ioConstantine Grigel
 
devops-complete-notes-2.pdf
devops-complete-notes-2.pdfdevops-complete-notes-2.pdf
devops-complete-notes-2.pdfRobinRohit2
 
Introducing Git and git flow
Introducing Git and git flow Introducing Git and git flow
Introducing Git and git flow Sebin Benjamin
 
Git Basics walkthough to all basic concept and commands of git
Git Basics walkthough to all basic concept and commands of gitGit Basics walkthough to all basic concept and commands of git
Git Basics walkthough to all basic concept and commands of gitDivyanshGupta922023
 
Git basics with notes
Git basics with notesGit basics with notes
Git basics with notesSurabhi Gupta
 
Git usage (Basics and workflow)
Git usage (Basics and workflow)Git usage (Basics and workflow)
Git usage (Basics and workflow)Yeasin Abedin
 
Beginner's Guide to Version Control with Git
Beginner's Guide to Version Control with GitBeginner's Guide to Version Control with Git
Beginner's Guide to Version Control with GitRobert Lee-Cann
 
SouthEast LinuxFest 2015 - intro to git
SouthEast LinuxFest 2015 -  intro to gitSouthEast LinuxFest 2015 -  intro to git
SouthEast LinuxFest 2015 - intro to gitedgester
 
01 git interview questions &amp; answers
01   git interview questions &amp; answers01   git interview questions &amp; answers
01 git interview questions &amp; answersDeepQuest Software
 
Git and git workflow best practice
Git and git workflow best practiceGit and git workflow best practice
Git and git workflow best practiceMajid Hosseini
 

Similaire à Git intermediate workshop slides v1.4 (20)

Command line git
Command line gitCommand line git
Command line git
 
Git of every day
Git of every dayGit of every day
Git of every day
 
Introduction to Git for developers
Introduction to Git for developersIntroduction to Git for developers
Introduction to Git for developers
 
Formation git
Formation gitFormation git
Formation git
 
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
 
BLUG 2012 Version Control for Notes Developers
BLUG 2012 Version Control for Notes DevelopersBLUG 2012 Version Control for Notes Developers
BLUG 2012 Version Control for Notes Developers
 
Git essential training & sharing self
Git essential training & sharing selfGit essential training & sharing self
Git essential training & sharing self
 
Microservices Development Process at Predix.io
Microservices Development Process at Predix.ioMicroservices Development Process at Predix.io
Microservices Development Process at Predix.io
 
devops-complete-notes-2.pdf
devops-complete-notes-2.pdfdevops-complete-notes-2.pdf
devops-complete-notes-2.pdf
 
Introducing Git and git flow
Introducing Git and git flow Introducing Git and git flow
Introducing Git and git flow
 
Git Basics walkthough to all basic concept and commands of git
Git Basics walkthough to all basic concept and commands of gitGit Basics walkthough to all basic concept and commands of git
Git Basics walkthough to all basic concept and commands of git
 
Git basics with notes
Git basics with notesGit basics with notes
Git basics with notes
 
Lets git to it
Lets git to itLets git to it
Lets git to it
 
Git usage (Basics and workflow)
Git usage (Basics and workflow)Git usage (Basics and workflow)
Git usage (Basics and workflow)
 
Git Basics
Git BasicsGit Basics
Git Basics
 
Beginner's Guide to Version Control with Git
Beginner's Guide to Version Control with GitBeginner's Guide to Version Control with Git
Beginner's Guide to Version Control with Git
 
An intro to git
An intro to gitAn intro to git
An intro to git
 
SouthEast LinuxFest 2015 - intro to git
SouthEast LinuxFest 2015 -  intro to gitSouthEast LinuxFest 2015 -  intro to git
SouthEast LinuxFest 2015 - intro to git
 
01 git interview questions &amp; answers
01   git interview questions &amp; answers01   git interview questions &amp; answers
01 git interview questions &amp; answers
 
Git and git workflow best practice
Git and git workflow best practiceGit and git workflow best practice
Git and git workflow best practice
 

Dernier

Busty Desi⚡Call Girls in Sector 51 Noida Escorts >༒8448380779 Escort Service-...
Busty Desi⚡Call Girls in Sector 51 Noida Escorts >༒8448380779 Escort Service-...Busty Desi⚡Call Girls in Sector 51 Noida Escorts >༒8448380779 Escort Service-...
Busty Desi⚡Call Girls in Sector 51 Noida Escorts >༒8448380779 Escort Service-...Delhi Call girls
 
SaaStr Workshop Wednesday w/ Lucas Price, Yardstick
SaaStr Workshop Wednesday w/ Lucas Price, YardstickSaaStr Workshop Wednesday w/ Lucas Price, Yardstick
SaaStr Workshop Wednesday w/ Lucas Price, Yardsticksaastr
 
Dreaming Music Video Treatment _ Project & Portfolio III
Dreaming Music Video Treatment _ Project & Portfolio IIIDreaming Music Video Treatment _ Project & Portfolio III
Dreaming Music Video Treatment _ Project & Portfolio IIINhPhngng3
 
Introduction to Prompt Engineering (Focusing on ChatGPT)
Introduction to Prompt Engineering (Focusing on ChatGPT)Introduction to Prompt Engineering (Focusing on ChatGPT)
Introduction to Prompt Engineering (Focusing on ChatGPT)Chameera Dedduwage
 
Report Writing Webinar Training
Report Writing Webinar TrainingReport Writing Webinar Training
Report Writing Webinar TrainingKylaCullinane
 
No Advance 8868886958 Chandigarh Call Girls , Indian Call Girls For Full Nigh...
No Advance 8868886958 Chandigarh Call Girls , Indian Call Girls For Full Nigh...No Advance 8868886958 Chandigarh Call Girls , Indian Call Girls For Full Nigh...
No Advance 8868886958 Chandigarh Call Girls , Indian Call Girls For Full Nigh...Sheetaleventcompany
 
BDSM⚡Call Girls in Sector 93 Noida Escorts >༒8448380779 Escort Service
BDSM⚡Call Girls in Sector 93 Noida Escorts >༒8448380779 Escort ServiceBDSM⚡Call Girls in Sector 93 Noida Escorts >༒8448380779 Escort Service
BDSM⚡Call Girls in Sector 93 Noida Escorts >༒8448380779 Escort ServiceDelhi Call girls
 
If this Giant Must Walk: A Manifesto for a New Nigeria
If this Giant Must Walk: A Manifesto for a New NigeriaIf this Giant Must Walk: A Manifesto for a New Nigeria
If this Giant Must Walk: A Manifesto for a New NigeriaKayode Fayemi
 
My Presentation "In Your Hands" by Halle Bailey
My Presentation "In Your Hands" by Halle BaileyMy Presentation "In Your Hands" by Halle Bailey
My Presentation "In Your Hands" by Halle Baileyhlharris
 
Sector 62, Noida Call girls :8448380779 Noida Escorts | 100% verified
Sector 62, Noida Call girls :8448380779 Noida Escorts | 100% verifiedSector 62, Noida Call girls :8448380779 Noida Escorts | 100% verified
Sector 62, Noida Call girls :8448380779 Noida Escorts | 100% verifiedDelhi Call girls
 
Thirunelveli call girls Tamil escorts 7877702510
Thirunelveli call girls Tamil escorts 7877702510Thirunelveli call girls Tamil escorts 7877702510
Thirunelveli call girls Tamil escorts 7877702510Vipesco
 
Air breathing and respiratory adaptations in diver animals
Air breathing and respiratory adaptations in diver animalsAir breathing and respiratory adaptations in diver animals
Air breathing and respiratory adaptations in diver animalsaqsarehman5055
 
The workplace ecosystem of the future 24.4.2024 Fabritius_share ii.pdf
The workplace ecosystem of the future 24.4.2024 Fabritius_share ii.pdfThe workplace ecosystem of the future 24.4.2024 Fabritius_share ii.pdf
The workplace ecosystem of the future 24.4.2024 Fabritius_share ii.pdfSenaatti-kiinteistöt
 
Bring back lost lover in USA, Canada ,Uk ,Australia ,London Lost Love Spell C...
Bring back lost lover in USA, Canada ,Uk ,Australia ,London Lost Love Spell C...Bring back lost lover in USA, Canada ,Uk ,Australia ,London Lost Love Spell C...
Bring back lost lover in USA, Canada ,Uk ,Australia ,London Lost Love Spell C...amilabibi1
 
BDSM⚡Call Girls in Sector 97 Noida Escorts >༒8448380779 Escort Service
BDSM⚡Call Girls in Sector 97 Noida Escorts >༒8448380779 Escort ServiceBDSM⚡Call Girls in Sector 97 Noida Escorts >༒8448380779 Escort Service
BDSM⚡Call Girls in Sector 97 Noida Escorts >༒8448380779 Escort ServiceDelhi Call girls
 
Dreaming Marissa Sánchez Music Video Treatment
Dreaming Marissa Sánchez Music Video TreatmentDreaming Marissa Sánchez Music Video Treatment
Dreaming Marissa Sánchez Music Video Treatmentnswingard
 
Chiulli_Aurora_Oman_Raffaele_Beowulf.pptx
Chiulli_Aurora_Oman_Raffaele_Beowulf.pptxChiulli_Aurora_Oman_Raffaele_Beowulf.pptx
Chiulli_Aurora_Oman_Raffaele_Beowulf.pptxraffaeleoman
 
Uncommon Grace The Autobiography of Isaac Folorunso
Uncommon Grace The Autobiography of Isaac FolorunsoUncommon Grace The Autobiography of Isaac Folorunso
Uncommon Grace The Autobiography of Isaac FolorunsoKayode Fayemi
 
Causes of poverty in France presentation.pptx
Causes of poverty in France presentation.pptxCauses of poverty in France presentation.pptx
Causes of poverty in France presentation.pptxCamilleBoulbin1
 

Dernier (20)

Busty Desi⚡Call Girls in Sector 51 Noida Escorts >༒8448380779 Escort Service-...
Busty Desi⚡Call Girls in Sector 51 Noida Escorts >༒8448380779 Escort Service-...Busty Desi⚡Call Girls in Sector 51 Noida Escorts >༒8448380779 Escort Service-...
Busty Desi⚡Call Girls in Sector 51 Noida Escorts >༒8448380779 Escort Service-...
 
SaaStr Workshop Wednesday w/ Lucas Price, Yardstick
SaaStr Workshop Wednesday w/ Lucas Price, YardstickSaaStr Workshop Wednesday w/ Lucas Price, Yardstick
SaaStr Workshop Wednesday w/ Lucas Price, Yardstick
 
ICT role in 21st century education and it's challenges.pdf
ICT role in 21st century education and it's challenges.pdfICT role in 21st century education and it's challenges.pdf
ICT role in 21st century education and it's challenges.pdf
 
Dreaming Music Video Treatment _ Project & Portfolio III
Dreaming Music Video Treatment _ Project & Portfolio IIIDreaming Music Video Treatment _ Project & Portfolio III
Dreaming Music Video Treatment _ Project & Portfolio III
 
Introduction to Prompt Engineering (Focusing on ChatGPT)
Introduction to Prompt Engineering (Focusing on ChatGPT)Introduction to Prompt Engineering (Focusing on ChatGPT)
Introduction to Prompt Engineering (Focusing on ChatGPT)
 
Report Writing Webinar Training
Report Writing Webinar TrainingReport Writing Webinar Training
Report Writing Webinar Training
 
No Advance 8868886958 Chandigarh Call Girls , Indian Call Girls For Full Nigh...
No Advance 8868886958 Chandigarh Call Girls , Indian Call Girls For Full Nigh...No Advance 8868886958 Chandigarh Call Girls , Indian Call Girls For Full Nigh...
No Advance 8868886958 Chandigarh Call Girls , Indian Call Girls For Full Nigh...
 
BDSM⚡Call Girls in Sector 93 Noida Escorts >༒8448380779 Escort Service
BDSM⚡Call Girls in Sector 93 Noida Escorts >༒8448380779 Escort ServiceBDSM⚡Call Girls in Sector 93 Noida Escorts >༒8448380779 Escort Service
BDSM⚡Call Girls in Sector 93 Noida Escorts >༒8448380779 Escort Service
 
If this Giant Must Walk: A Manifesto for a New Nigeria
If this Giant Must Walk: A Manifesto for a New NigeriaIf this Giant Must Walk: A Manifesto for a New Nigeria
If this Giant Must Walk: A Manifesto for a New Nigeria
 
My Presentation "In Your Hands" by Halle Bailey
My Presentation "In Your Hands" by Halle BaileyMy Presentation "In Your Hands" by Halle Bailey
My Presentation "In Your Hands" by Halle Bailey
 
Sector 62, Noida Call girls :8448380779 Noida Escorts | 100% verified
Sector 62, Noida Call girls :8448380779 Noida Escorts | 100% verifiedSector 62, Noida Call girls :8448380779 Noida Escorts | 100% verified
Sector 62, Noida Call girls :8448380779 Noida Escorts | 100% verified
 
Thirunelveli call girls Tamil escorts 7877702510
Thirunelveli call girls Tamil escorts 7877702510Thirunelveli call girls Tamil escorts 7877702510
Thirunelveli call girls Tamil escorts 7877702510
 
Air breathing and respiratory adaptations in diver animals
Air breathing and respiratory adaptations in diver animalsAir breathing and respiratory adaptations in diver animals
Air breathing and respiratory adaptations in diver animals
 
The workplace ecosystem of the future 24.4.2024 Fabritius_share ii.pdf
The workplace ecosystem of the future 24.4.2024 Fabritius_share ii.pdfThe workplace ecosystem of the future 24.4.2024 Fabritius_share ii.pdf
The workplace ecosystem of the future 24.4.2024 Fabritius_share ii.pdf
 
Bring back lost lover in USA, Canada ,Uk ,Australia ,London Lost Love Spell C...
Bring back lost lover in USA, Canada ,Uk ,Australia ,London Lost Love Spell C...Bring back lost lover in USA, Canada ,Uk ,Australia ,London Lost Love Spell C...
Bring back lost lover in USA, Canada ,Uk ,Australia ,London Lost Love Spell C...
 
BDSM⚡Call Girls in Sector 97 Noida Escorts >༒8448380779 Escort Service
BDSM⚡Call Girls in Sector 97 Noida Escorts >༒8448380779 Escort ServiceBDSM⚡Call Girls in Sector 97 Noida Escorts >༒8448380779 Escort Service
BDSM⚡Call Girls in Sector 97 Noida Escorts >༒8448380779 Escort Service
 
Dreaming Marissa Sánchez Music Video Treatment
Dreaming Marissa Sánchez Music Video TreatmentDreaming Marissa Sánchez Music Video Treatment
Dreaming Marissa Sánchez Music Video Treatment
 
Chiulli_Aurora_Oman_Raffaele_Beowulf.pptx
Chiulli_Aurora_Oman_Raffaele_Beowulf.pptxChiulli_Aurora_Oman_Raffaele_Beowulf.pptx
Chiulli_Aurora_Oman_Raffaele_Beowulf.pptx
 
Uncommon Grace The Autobiography of Isaac Folorunso
Uncommon Grace The Autobiography of Isaac FolorunsoUncommon Grace The Autobiography of Isaac Folorunso
Uncommon Grace The Autobiography of Isaac Folorunso
 
Causes of poverty in France presentation.pptx
Causes of poverty in France presentation.pptxCauses of poverty in France presentation.pptx
Causes of poverty in France presentation.pptx
 

Git intermediate workshop slides v1.4

  • 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 basic idea ● Frequent: ○ Do some work ○ Save and store away a copy of your work at a certain point in time ○ Give each copy a name for future reference ● Once in a while: ○ Be able to go “back in time” to see what changed ○ Possibly discard recent work and start over from a previous point ○ Communicate your changes to others Analogy: Savegame
  • 7. Story of a file ● Corso Git Trieste - materiale di presentazione v1.1
  • 8. Story of a file ● Corso Git Trieste - materiale di presentazione v1.1 ● Git Workshop slides v1.2
  • 9. Story of a file ● Corso Git Trieste - materiale di presentazione v1.1 ● Git Workshop slides v1.2 ● Git Workshop slides v1.2 - DS
  • 10. Story of a file ● Corso Git Trieste - materiale di presentazione v1.1 ● Git Workshop slides v1.2 ● Git Workshop slides v1.2 - DS ● Git Workshop slides v1.2 - RF
  • 11. Story of a file ● Corso Git Trieste - materiale di presentazione v1.1 ● Git Workshop slides v1.2 ● Git Workshop slides v1.2 - DS ● Git Workshop slides v1.2 - RF ● Git Workshop slides v1.2 - DS + FD
  • 12. Story of a file ● Corso Git Trieste - materiale di presentazione v1.1 ● Git Workshop slides v1.2 ● Git Workshop slides v1.2 - DS ● Git Workshop slides v1.2 - RF ● Git Workshop slides v1.2 - DS + FD ● Git Workshop slides v1.3
  • 13. Story of a file ● Corso Git Trieste - materiale di presentazione v1.1 ● Git Workshop slides v1.2 ● Git Workshop slides v1.2 - DS ● Git Workshop slides v1.2 - RF ● Git Workshop slides v1.2 - DS + FD ● Git Workshop slides v1.3 ● Git Workshop slides v1.4
  • 14. Story of a file ● Corso Git Trieste - materiale di presentazione v1.1 ● Git Workshop slides v1.2 ● Git Workshop slides v1.2 - DS ● Git Workshop slides v1.2 - RF ● Git Workshop slides v1.2 - DS + FD ● Git Workshop slides v1.3 ● Git Workshop slides v1.4 Are these all the same file? What’s the sequence?
  • 15. What we want to capture Most of the times saving a single file is not enough - information is often distributed and correlated. In computer programs, changes to one file are often strongly related to changes in other files - to the point our program breaks down if we take into account only the changes from one file. What we are really interested in (each time) is: ● what changed (files) ● where did I start from (previous version) ● who changed it (useful when multiple people collaborate) ● when it changed ● why it changed ● some kind of handle to reference each of such changes
  • 16. 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
  • 17. Creating a commit 1. Create / edit files on your working copy (your local filesystem) 2. Mark your changes for inclusion by copying them in the staging area 3. Create a new commit, providing the missing (meta) data ● What goes in the commit comes from: ○ whatever you put in the staging area (the “what”) ○ your git configuration: ■ your name & email (the “who”) ○ the (git) environment : ■ the current date (the “when”) ■ the commit you started working from (the “where”) ○ the message you specify (the “why”) ○ the commit itself (commit id, the “handle”)
  • 21. 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>
  • 22. Version control landscape Git Mercurial (HG) SVN ClearCase Transaction unit Commit Commit Commit File Storage model Snapshot Delta Delta ? Model Distributed (clone) Distributed (clone) Centralized (checkout) Centralized (checkout) 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*
  • 24. 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
  • 25. 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
  • 26. The git graph ● Each branch tracks either (or both): ○ alternate “timelines” ○ parallel work
  • 27. Showing the Git graph ● Some examples: ○ git log --graph --decorate --all --abbrev-commit --pretty=oneline ○ git log --graph --decorate --all --abbrev-commit --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C (reset)%C(bold yellow)%d%C(reset)%n'' %C(white)%s%C(reset) %C (dim white)- %an%C(reset)' ● Found a combination you like? keep it as an alias: ○ git config --global alias.graph "log --graph --decorate --all --abbrev- commit --pretty=oneline"
  • 28. Showing the Git graph (tools)
  • 29. Inside a commit ● id ● parent id(s) ● timestamp ● author (& committer) ● message ● content ○ filesystem state ● NOT part of a commit ○ branch ○ tags
  • 30. 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
  • 31. references: Branches ● a “branch” identifies a sequence of commits, tracing a workflow ● “master” is by convention the project main line ● A branch ref 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
  • 32. 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 ○ even if there are branches referencing that same commit
  • 33. 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
  • 34. Alternate (time)lines ● Creating alternate lines of work ○ branch ● Navigating the graph ○ checkout ○ reset ● “Crossing the streams” and other weird stuff ○ merging ○ git merge-based <ref> <ref> ○ git config --global merge.conflictstyle diff3 (merge) ○ git merge -Xignore-all-space (-Xignore-space-change) ○ rebasing ○ cherry-picking
  • 35. 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
  • 36. ● 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. https://git-scm.com/book/it/v2/Git-Internals-Git-References ● tracking branches ○ local branches bound to a remote branch ○ git checkout --track (remote)/(branch) ○ tracks your work on that branch to allow sync Remotes, refs, tracking branches
  • 37. Synchronization & collaboration ● clone ● push ● fetch ● pull (fetch+merge o fetch+rebase)
  • 38. Collaborative workflow ● commit message ● approaches (not exclusive) ○ based on merge ○ based on rebase
  • 40. Version control landscape Git Mercurial (HG) SVN ClearCase Transaction unit Commit Commit Commit File Storage model Snapshot Delta Delta ? Model Distributed (clone) Distributed (clone) Centralized (checkout) Centralized (checkout) 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*
  • 41. .gitignore ● Ignores untracked files in the folder or subfolders ● useful to ignore contents generated on the fly, or custom settings files (e. g.: IDE configuration for the project) ● Useful templates: ○ https://github.com/github/gitignore ○ https://help.github.com/articles/ignoring-files/
  • 42. git as a service ● github, gitlab, bitbucket ● basic concepts mapping ● Authorization models ● “Fork” and “Pull Request” implementations ○ pull request - “Please, take my changes”
  • 43.
  • 45. 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 ■ Git workflows comparison: https://www.atlassian.com/git/tutorials/comparing-workflows ■ Cache your passwords: https://help.github.com/articles/caching-your-github-password-in-git/ ■ Git-scm book (https://git-scm.com/book/en/v2), 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/ ■ Nice course: http://gitimmersion.com/index.html ■ Nice tool to create demo graphs: http://gitgraphjs.com/ ■ Git cheat sheet: http://zeroturnaround.com/rebellabs/git-commands-and-best-practices-cheat-sheet/ ■ Interesting videos: ● Introduction to Git with Scott Chacon of GitHub: https://www.youtube.com/watch?v=ZDR433b0HJY ● Brilliant representation of the graph: https://www.youtube.com/watch?v=1ffBJ4sVUb4