SlideShare a Scribd company logo
1 of 136
Download to read offline
From
SVN
to
Git
Note / disclaimer: these slides may be shared as
a PDF for the sake of interoperability, but they are
intended to be seen as an animation. It is recommended
to disable the “Continuous View” feature of your
PDF reader so you can see one slide at a time.
So you are familiar with SVN
So you are familiar with SVN
(or maybe even CVS)
and want to learn about Git?
Very good!
First thing you need to know is that
SVN is a centralised
version control system
(so is CVS and others)
while
Git is a distributed
version control system
(so is Mercurial and others)
The second thing you need to know is that
● centralised is
– older
– more common (for now)
● distributed is
– newer
– better
It is easy to verify that
centralised is more common
and that distributed is more modern,
so we will not talk about that.
We will explain why distributed
is also better in a second,
but there is a third thing
you must know
just in case you are looking at these
slides trying to figure out whether to
learn one or the other.
Learning one is as easy as
learning the other as long as
you do not know anything of either.
If you already know about distributed
version control systems, changing to
centralised is easy.
If you already know about distributed
version control systems, changing to
centralised is easy.
The opposite is not true.
So if you have never used a version
control system, close these slides,
learn about Git, and move on.
But you, reader who are
already familiar with SVN,
please continue.
Let me convince you to
change to Git
Let me convince you to
change to Git
(or Mercurial, or any distributed VCS)
and never look back.
and never look back.
Ready?
Let's start by looking at how SVN works
In SVN there is a server...
...and several clients
...and several clients
(in between, the network)
The server is the centralised
source of truth
The source code is initialised at the server
and then clients can get it.
svn checkout
After making a change, clients
commit to the server
svn commit
Other clients can check out too...
svn checkout
If a client has made changes that
are not on the server,
svn update
they must update before committing.
svn commit: FAIL
they must update before committing.
svn update
they must update before committing.
svn commit: SUCCESS
At update time, if the code on the server
cannot be merged with the client code
svn update
there is a conflict
svn update: CONFLICT
that must be solved before committing.
svn commit: FAIL because CONFLICT
This apparently simple explanation
of SVN is enough to highlight
its three main limitations.
● SVN...
– ...is slow
– ...cannot work offline
– ...does not scale
● And on top of all that
– ...branches are a nightmare
SLOW: evident, every commit
goes through the network
svn commit
● Being slow is not only a nuisance
● It provides a unconsciously powerful
incentive to use version control sparingly
instead of profusely (as it should)
● “I just changed a line, there is no need
to commit yet”
● “I will fix this other thing first and then
commit all”
● Wrong: commits should be atomic
● Remember that the main use of version
control is finding bugs retroactively.
The smaller the commits, the better.
ONLY ONLINE: evident,
all goes through the network
svn commit svn update -r 32144
● But the network is not always there!
– Planes, mountain retreats, 3G/4G
failures, airports, bad hotels...
● What do you do when you do not have
network connectivity?
– Do you stop working?
– Or do you stop using version control
and then commit a huge 200-lines
commit fixing five bugs and adding
two features?
● But the network is not always there!
– Planes, mountain retreats, 3G/4G
failures, airports, bad hotels...
● What do you do when you do not have
network connectivity?
– Do you stop working?
– Or do you stop using version control
and then commit a huge 200-lines
commit fixing five bugs and adding
two features?
– Both options are wrong!
NO SCALABILITY: this is not evident...
svn commit svn update
...but we have seen that every time
there is a commit on the system...
svn commit svn update
...there is a chance of creating a conflict
with someone else.
svn commit svn update: CONFLICT
This is quite annoying
and breaks the flow of work.
svn commit svn update: CONFLICT
In a project of 3 programmers,
conflict happens sometimes.
svn commit svn update: CONFLICT
In a project of 30 programmers,
conflict happens often.
svn commit
svn update: CONFLICT
In a project of 300 programmers,
conflict happens all the time to everybody.
svn commit
svn update: CONFLICT
Additionally, creating and merging
branches in SVN is a nightmare.
Branches are important in project
where not all the code is visible
all the time
experimental features
code not mature
different features for different clients
All of that is quite difficult in SVN.
Let's see how Git works
to solve all these problems!
Git is not centralised but distributed
This means that there is not one server...
...but many
Actually, there is one per computer.
In Git, every computer is a server
and version control happens locally...
● ...which means version control is...
– fast,
– works offline,
– and scales!
● It also means that setting a new git repo
is trivial!
● To start working with SVN you need to
put up a server or to have access to a
server. In git you just say 'git init' and
you are ready to go!
FAST: commits are local, so they
are instantaneus and cheap
git commit
OFFLINE: operations are local,
no network needed
git commit git branch
OFFLINE: operations are local,
no network needed
(only for sharing with others... we will come to that in a second)
git commit git branch
Let's talk about sharing before we
talk about scalability
How do your share your code
with your project mates in Git
...?
How do your share your code
with your project mates in Git
...if commits are local?
You pull their commits from them
(and so do they with yours)
git pull
git pull
git pull
When you pull from someone, you
do two things: you checkout their
commits, and then you merge them
with your code.
git pull = git checkout + git merge
git pull = git checkout + git merge
Beware! This “git checkout” does not mean exactly the
same as “svn checkout”, it only means “get all the
commits from that machine”, it does not start a local
repository as in SVN.
Most of the time, most people just pull
(instead of first checking out and then merging)
This distributed approach works well,
and scales perfectly, but
there is still one small problem...
...how do I know where is your machine?
Do I need to remember your IP address
or DNS name (if you have one)?
That is why most people use a
public repository where they
make their changes public.
(GitHub is just one of the most
well-known public repository holders)
In the same way that you can pull
someone else's repository...
...you can push your local changes
into a remote repository
(as long as it is yours,
i.e. you have permission)
and then others can pull from that
public repository of yours, because
it is at a well-known location.
So the usual picture looks like this:
GitHub
git commit
So the usual picture looks like this:
GitHub
git push
So the usual picture looks like this:
GitHub
git pull
So the usual picture looks like this:
GitHub
git commit git commit
So the usual picture looks like this:
GitHub
git push git push
note that the first programmer
does not pull from the fourth
GitHub
git pull
maybe they do not know each
other, or they do not trust each other
GitHub
git pull
but maybe programmer 2
trusts programmer 4
GitHub
git pull
but maybe programmer 2
trusts programmer 4
GitHub
git push
and pr1 trusts pr2
to get things right
GitHub
git pull
solving all conflicts that untrusted
(for pr1) programmers may cause
GitHub
git pull
Its distributed nature is what
makes Git so scalable.
Is SVN you must trust
everybody
Is SVN you must trust
everybody
because everybody can
mess up everybody else
Is SVN you must trust
everybody
because everybody can
mess up everybody else
(e.g. committing code
Is SVN you must trust
everybody
because everybody can
mess up everybody else
(e.g. committing code
but forgetting that new file
and then nothing compiles)
In Git you must only trust
your “selected few”, the few
people you pull from.
There are thousands of people
working on the linux kernel
but Linus Torvalds only pulls
from a handful of them.
If someone messes up, only those
in their circle are affected,
and the issue is fixed
before it spreads
to the whole community.
● The only way of doing this in SVN is by
not using SVN
– Some people have access to the server
and some do not
– Code reviews are performed out-of-the-
system before committing is allowed
– Political battles for access to the server
– etc
In Git, everything is under version
control all the time.
Nothing is ever lost.
I will repeat this because it is important:
“Nothing is ever lost”
On Git every single machine (potentially) has
the whole history of the project.
This is total security against
data loss
Your machine burnt in a fire?
Stolen? Eaten by your dog?
No problem!
Just clone from somebody and
you have everything again!
(except those things you had not pushed today, of course)
In centralised systems like SVN
the server is a central point
of failure. If you lose the server,
you lose all your history, your
branches, all your version control.
Sure, having the whole history on every
single repo uses a lot of disk space!
But when was the last time you
filled up a hard disk by writing code?
(not downloading movies) ;-)
In summary...
● Distributed version control is great
because:
– ...
In summary...
● Distributed version control is great
because:
– It is fast
In summary...
● Distributed version control is great
because:
– It is fast
– It is local (no network)
In summary...
● Distributed version control is great
because:
– It is fast
– It is local (no network)
– It scales seamlessly
In summary...
● Distributed version control is great
because:
– It is fast
– It is local (no network)
– It scales seamlessly
– It is safer
In summary...
● Distributed version control is great
because:
– It is fast
– It is local (no network)
– It scales seamlessly
– It is safer
● And if that were not enough to never look at
SVN again, Git also:
In summary...
● Distributed version control is great
because:
– It is fast
– It is local (no network)
– It scales seamlessly
– It is safer
● And if that were not enough to never look at
SVN again, Git also:
– Makes creating, managing, and merging branches
very easy
In summary...
● Distributed version control is great
because:
– It is fast
– It is local (no network)
– It scales seamlessly
– It is safer
● And if that were not enough to never look at
SVN again, Git also:
– Makes creating, managing, and merging branches
very easy
– Makes repository creation trivial
Quick SVN->Git translation
Let's see quickly what are the
commands for the most common
operations in SVN and Git
Quick SVN->Git translation
● Getting a copy of a repository
– In SVN, 'svn checkout'
– In Git, 'git clone'
– No big differences here
Quick SVN->Git translation
● Committing new code
– In SVN, 'svn commit'
– In Git, 'git commit'
– But we have seen that git's commit is
● local
● very fast
Quick SVN->Git translation
● Committing new code publicly
– In SVN, 'svn commit'
– In Git, 'git push'
– Commits are local in Git, and that (usually) means non-visible
– In other to publish them to other team members, they have to
be pushed to a well-known location
– Pushing is slow, like svn-commit, but it only happens once or
twice per day, typically.
– In SVN, your commit reaches everyone. In Git it reaches only
people who trust you enough to pull from you.
Quick SVN->Git translation
● Getting code written by others
– In SVN, 'svn update'
– In Git, 'git pull'
– No big differences here either, but
● in SVN, you always pull from the server
● in Git, you can pull from different people's (from their
machines, from their GitHub's account, or similar)
Quick SVN->Git translation
● Most other commands have similar
syntaxes to SVN's
– There are also a lot of new commands, but clone + commit +
+ push + pull will be 95% of your use of Git
– Remember: 'git help <command>' is always your friend
Happy hacking!

More Related Content

What's hot

From svn to git
From svn to gitFrom svn to git
From svn to gitNehal Shah
 
Training: Day Two - Eclipse, Git, Maven
Training: Day Two - Eclipse, Git, MavenTraining: Day Two - Eclipse, Git, Maven
Training: Day Two - Eclipse, Git, MavenArtur Ventura
 
Git for IBM Notes Designer
Git for IBM Notes DesignerGit for IBM Notes Designer
Git for IBM Notes DesignerSlobodan Lohja
 
Advanced Git Tutorial
Advanced Git TutorialAdvanced Git Tutorial
Advanced Git TutorialSage Sharp
 
Github - Git Training Slides: Foundations
Github - Git Training Slides: FoundationsGithub - Git Training Slides: Foundations
Github - Git Training Slides: FoundationsLee Hanxue
 
Git the fast version control system
Git the fast version control systemGit the fast version control system
Git the fast version control systemJeroen Rosenberg
 
Using Git with Drupal
Using Git with DrupalUsing Git with Drupal
Using Git with DrupalRyan Cross
 
Git Introduction Tutorial
Git Introduction TutorialGit Introduction Tutorial
Git Introduction TutorialThomas Rausch
 
Intro to git and git hub
Intro to git and git hubIntro to git and git hub
Intro to git and git hubVenkat Malladi
 
Source Control with Domino Designer 8.5.3 and Git (DanNotes, November 28, 2012)
Source Control with Domino Designer 8.5.3 and Git (DanNotes, November 28, 2012)Source Control with Domino Designer 8.5.3 and Git (DanNotes, November 28, 2012)
Source Control with Domino Designer 8.5.3 and Git (DanNotes, November 28, 2012)Per Henrik Lausten
 
The everyday developer's guide to version control with Git
The everyday developer's guide to version control with GitThe everyday developer's guide to version control with Git
The everyday developer's guide to version control with GitE Carter
 
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
 

What's hot (20)

From svn to git
From svn to gitFrom svn to git
From svn to git
 
Training: Day Two - Eclipse, Git, Maven
Training: Day Two - Eclipse, Git, MavenTraining: Day Two - Eclipse, Git, Maven
Training: Day Two - Eclipse, Git, Maven
 
Git for IBM Notes Designer
Git for IBM Notes DesignerGit for IBM Notes Designer
Git for IBM Notes Designer
 
Git basic
Git basicGit basic
Git basic
 
Introduction git
Introduction gitIntroduction git
Introduction git
 
Advanced Git Tutorial
Advanced Git TutorialAdvanced Git Tutorial
Advanced Git Tutorial
 
Github - Git Training Slides: Foundations
Github - Git Training Slides: FoundationsGithub - Git Training Slides: Foundations
Github - Git Training Slides: Foundations
 
Git basics
Git basicsGit basics
Git basics
 
Git the fast version control system
Git the fast version control systemGit the fast version control system
Git the fast version control system
 
Using Git with Drupal
Using Git with DrupalUsing Git with Drupal
Using Git with Drupal
 
Git Introduction Tutorial
Git Introduction TutorialGit Introduction Tutorial
Git Introduction Tutorial
 
Git for beginners
Git for beginnersGit for beginners
Git for beginners
 
Git
GitGit
Git
 
Git tutorial
Git tutorial Git tutorial
Git tutorial
 
Intro to git and git hub
Intro to git and git hubIntro to git and git hub
Intro to git and git hub
 
Source Control with Domino Designer 8.5.3 and Git (DanNotes, November 28, 2012)
Source Control with Domino Designer 8.5.3 and Git (DanNotes, November 28, 2012)Source Control with Domino Designer 8.5.3 and Git (DanNotes, November 28, 2012)
Source Control with Domino Designer 8.5.3 and Git (DanNotes, November 28, 2012)
 
Git Presentation
Git PresentationGit Presentation
Git Presentation
 
Git
GitGit
Git
 
The everyday developer's guide to version control with Git
The everyday developer's guide to version control with GitThe everyday developer's guide to version control with Git
The everyday developer's guide to version control with Git
 
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
 

Viewers also liked

Comparison of SVN and Git
Comparison of SVN and GitComparison of SVN and Git
Comparison of SVN and GitDaniel Wieth
 
Git vs SVN
Git vs SVNGit vs SVN
Git vs SVNneuros
 
Quick Introduction to git
Quick Introduction to gitQuick Introduction to git
Quick Introduction to gitJoel Krebs
 
Getting started with git svn
Getting started with git svnGetting started with git svn
Getting started with git svnManij Shrestha
 
Subversion Overview
Subversion OverviewSubversion Overview
Subversion Overviewpolarion
 
SVN Best Practices
SVN Best PracticesSVN Best Practices
SVN Best Practicesabackstrom
 
Git: A Getting Started Presentation
Git: A Getting Started PresentationGit: A Getting Started Presentation
Git: A Getting Started PresentationNap Ramirez
 
Présentation Raspberry Pi (cocoaheads remix)
Présentation Raspberry Pi (cocoaheads remix)Présentation Raspberry Pi (cocoaheads remix)
Présentation Raspberry Pi (cocoaheads remix)Arnaud Boudou
 
Introduction to EDI(Electronic Data Interchange)
Introduction to EDI(Electronic Data Interchange)Introduction to EDI(Electronic Data Interchange)
Introduction to EDI(Electronic Data Interchange)Siva Arunachalam
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to GitLukas Fittl
 
1 electronic data interchange (edi)
1   electronic data interchange (edi)1   electronic data interchange (edi)
1 electronic data interchange (edi)gauravashq
 

Viewers also liked (20)

Comparison of SVN and Git
Comparison of SVN and GitComparison of SVN and Git
Comparison of SVN and Git
 
GIT / SVN
GIT / SVNGIT / SVN
GIT / SVN
 
Git vs SVN
Git vs SVNGit vs SVN
Git vs SVN
 
SVN 2 Git
SVN 2 GitSVN 2 Git
SVN 2 Git
 
Introduction to git
Introduction to gitIntroduction to git
Introduction to git
 
Quick Introduction to git
Quick Introduction to gitQuick Introduction to git
Quick Introduction to git
 
Getting started with git svn
Getting started with git svnGetting started with git svn
Getting started with git svn
 
Git vs svn
Git vs svnGit vs svn
Git vs svn
 
Git Tech Talk
Git  Tech TalkGit  Tech Talk
Git Tech Talk
 
Subversion Overview
Subversion OverviewSubversion Overview
Subversion Overview
 
SVN Best Practices
SVN Best PracticesSVN Best Practices
SVN Best Practices
 
Git: A Getting Started Presentation
Git: A Getting Started PresentationGit: A Getting Started Presentation
Git: A Getting Started Presentation
 
What Is EDI: Whitepaper Download
What Is EDI: Whitepaper DownloadWhat Is EDI: Whitepaper Download
What Is EDI: Whitepaper Download
 
Git Introduction
Git IntroductionGit Introduction
Git Introduction
 
Présentation Raspberry Pi (cocoaheads remix)
Présentation Raspberry Pi (cocoaheads remix)Présentation Raspberry Pi (cocoaheads remix)
Présentation Raspberry Pi (cocoaheads remix)
 
Introduction to EDI(Electronic Data Interchange)
Introduction to EDI(Electronic Data Interchange)Introduction to EDI(Electronic Data Interchange)
Introduction to EDI(Electronic Data Interchange)
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Git
 
Svn Basic Tutorial
Svn Basic TutorialSvn Basic Tutorial
Svn Basic Tutorial
 
Intro To Git
Intro To GitIntro To Git
Intro To Git
 
1 electronic data interchange (edi)
1   electronic data interchange (edi)1   electronic data interchange (edi)
1 electronic data interchange (edi)
 

Similar to From SVN to Git

Git: The Lean, Mean, Distributed Machine
Git: The Lean, Mean, Distributed MachineGit: The Lean, Mean, Distributed Machine
Git: The Lean, Mean, Distributed Machineerr
 
TechTalk5-WhatDoesItTakeToRunLLVMBuildbots.pdf
TechTalk5-WhatDoesItTakeToRunLLVMBuildbots.pdfTechTalk5-WhatDoesItTakeToRunLLVMBuildbots.pdf
TechTalk5-WhatDoesItTakeToRunLLVMBuildbots.pdfxiso
 
Git_tutorial.pdf
Git_tutorial.pdfGit_tutorial.pdf
Git_tutorial.pdfAliaaTarek5
 
Git for a newbie
Git for a newbieGit for a newbie
Git for a newbieAnuj Sharma
 
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
 
Version Uncontrolled - How to Manage Your Version Control (whitepaper)
Version Uncontrolled - How to Manage Your Version Control (whitepaper)Version Uncontrolled - How to Manage Your Version Control (whitepaper)
Version Uncontrolled - How to Manage Your Version Control (whitepaper)Revelation Technologies
 
Introduction to Git for Non-Developers
Introduction to Git for Non-DevelopersIntroduction to Git for Non-Developers
Introduction to Git for Non-DevelopersAll Things Open
 
Introduction to Git for Non-Developers
Introduction to Git for Non-DevelopersIntroduction to Git for Non-Developers
Introduction to Git for Non-DevelopersJohn Anderson
 
What every C++ programmer should know about modern compilers (w/ comments, AC...
What every C++ programmer should know about modern compilers (w/ comments, AC...What every C++ programmer should know about modern compilers (w/ comments, AC...
What every C++ programmer should know about modern compilers (w/ comments, AC...Sławomir Zborowski
 
Sensepost assessment automation
Sensepost assessment automationSensepost assessment automation
Sensepost assessment automationSensePost
 
Cfgmgmt Challenges aren't technical anymore
Cfgmgmt Challenges aren't technical anymoreCfgmgmt Challenges aren't technical anymore
Cfgmgmt Challenges aren't technical anymoreJulien Pivotto
 
Mozammel Haque: Git -- Stupid, Fast, distributed content tracker
Mozammel Haque: Git -- Stupid, Fast, distributed content trackerMozammel Haque: Git -- Stupid, Fast, distributed content tracker
Mozammel Haque: Git -- Stupid, Fast, distributed content trackerSQABD
 
Version Control Systems -- Git -- Part I
Version Control Systems -- Git -- Part IVersion Control Systems -- Git -- Part I
Version Control Systems -- Git -- Part ISergey Aganezov
 
The internet of $h1t
The internet of $h1tThe internet of $h1t
The internet of $h1tAmit Serper
 
DECODING LEGACY: A JOURNEY THROUGH COMMIT MESSAGES
DECODING LEGACY: A JOURNEY THROUGH COMMIT MESSAGESDECODING LEGACY: A JOURNEY THROUGH COMMIT MESSAGES
DECODING LEGACY: A JOURNEY THROUGH COMMIT MESSAGESAirton Zanon
 
Lesson 0.5 Introduction to Git (1).pptx
Lesson 0.5 Introduction to Git (1).pptxLesson 0.5 Introduction to Git (1).pptx
Lesson 0.5 Introduction to Git (1).pptxAliSaeed579036
 

Similar to From SVN to Git (20)

Git: The Lean, Mean, Distributed Machine
Git: The Lean, Mean, Distributed MachineGit: The Lean, Mean, Distributed Machine
Git: The Lean, Mean, Distributed Machine
 
TechTalk5-WhatDoesItTakeToRunLLVMBuildbots.pdf
TechTalk5-WhatDoesItTakeToRunLLVMBuildbots.pdfTechTalk5-WhatDoesItTakeToRunLLVMBuildbots.pdf
TechTalk5-WhatDoesItTakeToRunLLVMBuildbots.pdf
 
Git_tutorial.pdf
Git_tutorial.pdfGit_tutorial.pdf
Git_tutorial.pdf
 
Git for a newbie
Git for a newbieGit for a newbie
Git for a newbie
 
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
 
Gitting better
Gitting betterGitting better
Gitting better
 
Version Uncontrolled - How to Manage Your Version Control (whitepaper)
Version Uncontrolled - How to Manage Your Version Control (whitepaper)Version Uncontrolled - How to Manage Your Version Control (whitepaper)
Version Uncontrolled - How to Manage Your Version Control (whitepaper)
 
Introduction to Git for Non-Developers
Introduction to Git for Non-DevelopersIntroduction to Git for Non-Developers
Introduction to Git for Non-Developers
 
Introduction to Git for Non-Developers
Introduction to Git for Non-DevelopersIntroduction to Git for Non-Developers
Introduction to Git for Non-Developers
 
Getting Git
Getting GitGetting Git
Getting Git
 
12 tricks to avoid hackers breaks your CI / CD
12 tricks to avoid hackers breaks your  CI / CD12 tricks to avoid hackers breaks your  CI / CD
12 tricks to avoid hackers breaks your CI / CD
 
What every C++ programmer should know about modern compilers (w/ comments, AC...
What every C++ programmer should know about modern compilers (w/ comments, AC...What every C++ programmer should know about modern compilers (w/ comments, AC...
What every C++ programmer should know about modern compilers (w/ comments, AC...
 
Sensepost assessment automation
Sensepost assessment automationSensepost assessment automation
Sensepost assessment automation
 
Cfgmgmt Challenges aren't technical anymore
Cfgmgmt Challenges aren't technical anymoreCfgmgmt Challenges aren't technical anymore
Cfgmgmt Challenges aren't technical anymore
 
Mozammel Haque: Git -- Stupid, Fast, distributed content tracker
Mozammel Haque: Git -- Stupid, Fast, distributed content trackerMozammel Haque: Git -- Stupid, Fast, distributed content tracker
Mozammel Haque: Git -- Stupid, Fast, distributed content tracker
 
Version Control Systems -- Git -- Part I
Version Control Systems -- Git -- Part IVersion Control Systems -- Git -- Part I
Version Control Systems -- Git -- Part I
 
The internet of $h1t
The internet of $h1tThe internet of $h1t
The internet of $h1t
 
DECODING LEGACY: A JOURNEY THROUGH COMMIT MESSAGES
DECODING LEGACY: A JOURNEY THROUGH COMMIT MESSAGESDECODING LEGACY: A JOURNEY THROUGH COMMIT MESSAGES
DECODING LEGACY: A JOURNEY THROUGH COMMIT MESSAGES
 
Lesson 0.5 Introduction to Git (1).pptx
Lesson 0.5 Introduction to Git (1).pptxLesson 0.5 Introduction to Git (1).pptx
Lesson 0.5 Introduction to Git (1).pptx
 

Recently uploaded

Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...OnePlan Solutions
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Hr365.us smith
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfAlina Yurenko
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
How to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdfHow to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdfLivetecs LLC
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)jennyeacort
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfStefano Stabellini
 
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in NoidaBuds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in Noidabntitsolutionsrishis
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....kzayra69
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 

Recently uploaded (20)

Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)
 
2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
How to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdfHow to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdf
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdf
 
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in NoidaBuds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 

From SVN to Git

  • 2. Note / disclaimer: these slides may be shared as a PDF for the sake of interoperability, but they are intended to be seen as an animation. It is recommended to disable the “Continuous View” feature of your PDF reader so you can see one slide at a time.
  • 3. So you are familiar with SVN
  • 4. So you are familiar with SVN (or maybe even CVS)
  • 5. and want to learn about Git?
  • 7. First thing you need to know is that
  • 8. SVN is a centralised version control system (so is CVS and others)
  • 10. Git is a distributed version control system (so is Mercurial and others)
  • 11. The second thing you need to know is that
  • 12. ● centralised is – older – more common (for now) ● distributed is – newer – better
  • 13. It is easy to verify that centralised is more common
  • 14. and that distributed is more modern, so we will not talk about that.
  • 15. We will explain why distributed is also better in a second,
  • 16. but there is a third thing you must know
  • 17. just in case you are looking at these slides trying to figure out whether to learn one or the other.
  • 18. Learning one is as easy as learning the other as long as you do not know anything of either.
  • 19. If you already know about distributed version control systems, changing to centralised is easy.
  • 20. If you already know about distributed version control systems, changing to centralised is easy. The opposite is not true.
  • 21. So if you have never used a version control system, close these slides, learn about Git, and move on.
  • 22. But you, reader who are already familiar with SVN, please continue.
  • 23. Let me convince you to change to Git
  • 24. Let me convince you to change to Git (or Mercurial, or any distributed VCS)
  • 25. and never look back.
  • 26. and never look back.
  • 28. Let's start by looking at how SVN works
  • 29. In SVN there is a server...
  • 31. ...and several clients (in between, the network)
  • 32. The server is the centralised source of truth
  • 33. The source code is initialised at the server
  • 34. and then clients can get it. svn checkout
  • 35. After making a change, clients commit to the server svn commit
  • 36. Other clients can check out too... svn checkout
  • 37. If a client has made changes that are not on the server, svn update
  • 38. they must update before committing. svn commit: FAIL
  • 39. they must update before committing. svn update
  • 40. they must update before committing. svn commit: SUCCESS
  • 41. At update time, if the code on the server cannot be merged with the client code svn update
  • 42. there is a conflict svn update: CONFLICT
  • 43. that must be solved before committing. svn commit: FAIL because CONFLICT
  • 44. This apparently simple explanation of SVN is enough to highlight its three main limitations.
  • 45. ● SVN... – ...is slow – ...cannot work offline – ...does not scale ● And on top of all that – ...branches are a nightmare
  • 46. SLOW: evident, every commit goes through the network svn commit
  • 47. ● Being slow is not only a nuisance ● It provides a unconsciously powerful incentive to use version control sparingly instead of profusely (as it should) ● “I just changed a line, there is no need to commit yet” ● “I will fix this other thing first and then commit all” ● Wrong: commits should be atomic ● Remember that the main use of version control is finding bugs retroactively. The smaller the commits, the better.
  • 48. ONLY ONLINE: evident, all goes through the network svn commit svn update -r 32144
  • 49. ● But the network is not always there! – Planes, mountain retreats, 3G/4G failures, airports, bad hotels... ● What do you do when you do not have network connectivity? – Do you stop working? – Or do you stop using version control and then commit a huge 200-lines commit fixing five bugs and adding two features?
  • 50. ● But the network is not always there! – Planes, mountain retreats, 3G/4G failures, airports, bad hotels... ● What do you do when you do not have network connectivity? – Do you stop working? – Or do you stop using version control and then commit a huge 200-lines commit fixing five bugs and adding two features? – Both options are wrong!
  • 51. NO SCALABILITY: this is not evident... svn commit svn update
  • 52. ...but we have seen that every time there is a commit on the system... svn commit svn update
  • 53. ...there is a chance of creating a conflict with someone else. svn commit svn update: CONFLICT
  • 54. This is quite annoying and breaks the flow of work. svn commit svn update: CONFLICT
  • 55. In a project of 3 programmers, conflict happens sometimes. svn commit svn update: CONFLICT
  • 56. In a project of 30 programmers, conflict happens often. svn commit svn update: CONFLICT
  • 57. In a project of 300 programmers, conflict happens all the time to everybody. svn commit svn update: CONFLICT
  • 58. Additionally, creating and merging branches in SVN is a nightmare.
  • 59. Branches are important in project where not all the code is visible all the time
  • 62. different features for different clients
  • 63. All of that is quite difficult in SVN.
  • 64. Let's see how Git works to solve all these problems!
  • 65. Git is not centralised but distributed
  • 66. This means that there is not one server...
  • 68. Actually, there is one per computer.
  • 69. In Git, every computer is a server
  • 70. and version control happens locally...
  • 71. ● ...which means version control is... – fast, – works offline, – and scales! ● It also means that setting a new git repo is trivial! ● To start working with SVN you need to put up a server or to have access to a server. In git you just say 'git init' and you are ready to go!
  • 72. FAST: commits are local, so they are instantaneus and cheap git commit
  • 73. OFFLINE: operations are local, no network needed git commit git branch
  • 74. OFFLINE: operations are local, no network needed (only for sharing with others... we will come to that in a second) git commit git branch
  • 75. Let's talk about sharing before we talk about scalability
  • 76. How do your share your code with your project mates in Git ...?
  • 77. How do your share your code with your project mates in Git ...if commits are local?
  • 78. You pull their commits from them (and so do they with yours)
  • 80. When you pull from someone, you do two things: you checkout their commits, and then you merge them with your code.
  • 81. git pull = git checkout + git merge
  • 82. git pull = git checkout + git merge Beware! This “git checkout” does not mean exactly the same as “svn checkout”, it only means “get all the commits from that machine”, it does not start a local repository as in SVN.
  • 83. Most of the time, most people just pull (instead of first checking out and then merging)
  • 84. This distributed approach works well, and scales perfectly, but there is still one small problem...
  • 85. ...how do I know where is your machine? Do I need to remember your IP address or DNS name (if you have one)?
  • 86. That is why most people use a public repository where they make their changes public.
  • 87. (GitHub is just one of the most well-known public repository holders)
  • 88. In the same way that you can pull someone else's repository...
  • 89. ...you can push your local changes into a remote repository (as long as it is yours, i.e. you have permission)
  • 90. and then others can pull from that public repository of yours, because it is at a well-known location.
  • 91. So the usual picture looks like this: GitHub git commit
  • 92. So the usual picture looks like this: GitHub git push
  • 93. So the usual picture looks like this: GitHub git pull
  • 94. So the usual picture looks like this: GitHub git commit git commit
  • 95. So the usual picture looks like this: GitHub git push git push
  • 96. note that the first programmer does not pull from the fourth GitHub git pull
  • 97. maybe they do not know each other, or they do not trust each other GitHub git pull
  • 98. but maybe programmer 2 trusts programmer 4 GitHub git pull
  • 99. but maybe programmer 2 trusts programmer 4 GitHub git push
  • 100. and pr1 trusts pr2 to get things right GitHub git pull
  • 101. solving all conflicts that untrusted (for pr1) programmers may cause GitHub git pull
  • 102. Its distributed nature is what makes Git so scalable.
  • 103. Is SVN you must trust everybody
  • 104. Is SVN you must trust everybody because everybody can mess up everybody else
  • 105. Is SVN you must trust everybody because everybody can mess up everybody else (e.g. committing code
  • 106. Is SVN you must trust everybody because everybody can mess up everybody else (e.g. committing code but forgetting that new file and then nothing compiles)
  • 107. In Git you must only trust your “selected few”, the few people you pull from.
  • 108. There are thousands of people working on the linux kernel
  • 109. but Linus Torvalds only pulls from a handful of them.
  • 110. If someone messes up, only those in their circle are affected,
  • 111. and the issue is fixed before it spreads to the whole community.
  • 112. ● The only way of doing this in SVN is by not using SVN – Some people have access to the server and some do not – Code reviews are performed out-of-the- system before committing is allowed – Political battles for access to the server – etc
  • 113. In Git, everything is under version control all the time.
  • 114. Nothing is ever lost.
  • 115. I will repeat this because it is important: “Nothing is ever lost”
  • 116. On Git every single machine (potentially) has the whole history of the project.
  • 117. This is total security against data loss
  • 118. Your machine burnt in a fire? Stolen? Eaten by your dog? No problem! Just clone from somebody and you have everything again! (except those things you had not pushed today, of course)
  • 119. In centralised systems like SVN the server is a central point of failure. If you lose the server, you lose all your history, your branches, all your version control.
  • 120. Sure, having the whole history on every single repo uses a lot of disk space!
  • 121. But when was the last time you filled up a hard disk by writing code? (not downloading movies) ;-)
  • 122. In summary... ● Distributed version control is great because: – ...
  • 123. In summary... ● Distributed version control is great because: – It is fast
  • 124. In summary... ● Distributed version control is great because: – It is fast – It is local (no network)
  • 125. In summary... ● Distributed version control is great because: – It is fast – It is local (no network) – It scales seamlessly
  • 126. In summary... ● Distributed version control is great because: – It is fast – It is local (no network) – It scales seamlessly – It is safer
  • 127. In summary... ● Distributed version control is great because: – It is fast – It is local (no network) – It scales seamlessly – It is safer ● And if that were not enough to never look at SVN again, Git also:
  • 128. In summary... ● Distributed version control is great because: – It is fast – It is local (no network) – It scales seamlessly – It is safer ● And if that were not enough to never look at SVN again, Git also: – Makes creating, managing, and merging branches very easy
  • 129. In summary... ● Distributed version control is great because: – It is fast – It is local (no network) – It scales seamlessly – It is safer ● And if that were not enough to never look at SVN again, Git also: – Makes creating, managing, and merging branches very easy – Makes repository creation trivial
  • 130. Quick SVN->Git translation Let's see quickly what are the commands for the most common operations in SVN and Git
  • 131. Quick SVN->Git translation ● Getting a copy of a repository – In SVN, 'svn checkout' – In Git, 'git clone' – No big differences here
  • 132. Quick SVN->Git translation ● Committing new code – In SVN, 'svn commit' – In Git, 'git commit' – But we have seen that git's commit is ● local ● very fast
  • 133. Quick SVN->Git translation ● Committing new code publicly – In SVN, 'svn commit' – In Git, 'git push' – Commits are local in Git, and that (usually) means non-visible – In other to publish them to other team members, they have to be pushed to a well-known location – Pushing is slow, like svn-commit, but it only happens once or twice per day, typically. – In SVN, your commit reaches everyone. In Git it reaches only people who trust you enough to pull from you.
  • 134. Quick SVN->Git translation ● Getting code written by others – In SVN, 'svn update' – In Git, 'git pull' – No big differences here either, but ● in SVN, you always pull from the server ● in Git, you can pull from different people's (from their machines, from their GitHub's account, or similar)
  • 135. Quick SVN->Git translation ● Most other commands have similar syntaxes to SVN's – There are also a lot of new commands, but clone + commit + + push + pull will be 95% of your use of Git – Remember: 'git help <command>' is always your friend