SlideShare uma empresa Scribd logo
1 de 27
Baixar para ler offline
   
Modern Source and
Version Control with Git
November 2016
Christian Couder
chriscool@tuxfamily.org
   
A Distributed Version Control System (DVCS):
● created by Linus Torvalds
● maintained by Junio Hamano
● since 2005
● Most popular VCS (~30% of developers)
About Git
   
● started developing Git in 2006
● worked especially on git bisect
● independent consultant working for Booking.com, 
GitLab and Protocol Labs
About myself
   
● Evolution of version control with Git
● Benefits in terms of quality and agility 
The plan
   
Easy to create and merge branches
● Before Git, branches were something “big”, slow 
and difficult to merge
● With Git, they are light and trivial
What is modern version control?
   
Why it changes everything?
● We want to create and merge many branches
● And we want to manage and automate the process
● This means we need:
– Feature branches
– Pull requests
– Complex workflows (like Git Flow)
   
Git Flow
   
Two possible reactions
● That's awesome and very smart!
● Help! I am scared, it's just too complex and 
unmanageable!
   
Let's keep history simple (stupid)!
We need something to linearize history!
=> git rebase is our friend
While at it, let's also merge or move or just remove 
commits!
=> git rebase ­i is our friend
   
Let's go with a complex history!
● git log ­­decorate ­­oneline –graph
will help visualize it!
● git bisect will help find bad commits
– We can even automate it with: git bisect run
– We can skip untestable commits with:
git bisect skip
   
Commits in Git form a DAG
(Directed Acyclic Graph)
●
history direction is from left to right
●
new commits point to their parents
   
First Bad Commit
B
●
B introduces a bad behavior called "bug" or "regression"
●
red commits are called "bad"
●
blue commits are called "good"
   
In the end it all comes together
● When using git rebase and git bisect we realize that 
they work together very well 
● Let's take a look for example at code review and 
testing
   
Why Code Review and Testing?
● They are the best way to improve: quality and agility
● Continuous Integration and Deployment rely on 
Code Review and Testing
Because you really don't want bugs in the product 
you give to your customer!
   
Modern Code Review 1
● It's when you “polish” (rework) your commits until it is 
clear that they are all good.
● This means you want:
– small commits
– good commit messages (that explain why)
   
Modern Code Review 2
git rebase ­i helps you rework commits:
● split them into smaller commits
● modify them and their commit message
   
Modern Testing
● Think black box test too, not just unit tests
● Test each commit: git rebase ­­exec <cmd>
● 1 test at least for each new feature
● 1 test at least for each bug (fixed, or not)
   
● 11 years ago Junio Hamano created the Git test 
framework (test­lib.sh)
● Developed in shell (POSIX /bin/sh compatible)
● Extracted 5 years ago by Mathias Lafeldt into a 
separate project called Sharness
● It's one of the main reasons why Git has always 
been very stable
Sharness
   
Why 1 test for each new feature?
● It shows the feature has been at least minimally 
tested
● It documents the feature
● It makes the reviewer's job easier
● It makes it easier to add more tests later
   
Why 1 test for each bug (fixed, or not)?
● It documents the bug
● It helps reproduce the bug
● It will make sure the bug will not reappear
● It makes the reviewer's job easier
● It's easy to do if there is already 1 test per feature
   
Using a git bisect based Test Workflow
● Write the test for a bug before fixing the bug
● Use git bisect run mytest to automatically find the 
commit that introduced the bug  
● Fix the bug (which should be easier)
● Commit the bug fix and the test together
   
Why a git bisect based test workflow?
● It make it easier to fix the bug
● Because it gives more accurate information
● It takes advantage of small commits
● It takes advantage of good commit messages
● People who have used it report great efficiency 
improvements
   
To conclude
Hopefully you now know what can be a modern 
version control with Git, especially:
● The evolution it represents, and the logic of this 
evolution 
● The benefits, in terms of quality and agility, through 
better code reviews and testing
   
Many thanks to:
● Junio Hamano, Linus Torvalds, Mathias Lafeldt
● many other great people in the Git and Linux communities
● Paris Open Source Summit organizers and attendants,
● Booking.com, GitLab and Protocol Labs, the companies I am working 
for.
   
● http://www.slideshare.net/ChristianCouder/
● https://semmle.com/customers/github­change­impact/
● http://git­scm.com
● https://github.com/chriscool/sharness
● https://github.com/chriscool/sharnessify
Links
   
Questions?
   
Idea:
● help find a first bad commit
● use a binary search algorithm for efficiency if 
possible
 
Benefits:
● manually verifying the source code changes 
from only one commit is relatively easy
● the commit gives extra information: commit 
message, author, ... 
Git bisect

Mais conteúdo relacionado

Mais procurados

Git tech talk
Git tech talkGit tech talk
Git tech talk
razasayed
 
Git - Drupalcamp Ireland Dublin 2010
Git - Drupalcamp Ireland Dublin 2010Git - Drupalcamp Ireland Dublin 2010
Git - Drupalcamp Ireland Dublin 2010
alanburke
 

Mais procurados (20)

Contributing to open source using Git
Contributing to open source using GitContributing to open source using Git
Contributing to open source using Git
 
Git: Git'ing the Basic
Git: Git'ing the BasicGit: Git'ing the Basic
Git: Git'ing the Basic
 
SCM Boot Camp
SCM Boot CampSCM Boot Camp
SCM Boot Camp
 
Git 1
Git 1Git 1
Git 1
 
Git
GitGit
Git
 
Git in Eclipse
Git in EclipseGit in Eclipse
Git in Eclipse
 
GIT - DUG Antwerp
GIT - DUG AntwerpGIT - DUG Antwerp
GIT - DUG Antwerp
 
Git training with Devaamo
Git training with DevaamoGit training with Devaamo
Git training with Devaamo
 
Khorshed presentation-digital world2016
Khorshed presentation-digital world2016Khorshed presentation-digital world2016
Khorshed presentation-digital world2016
 
Go in Production
Go in ProductionGo in Production
Go in Production
 
Helios in Action: Git at Eclipse
Helios in Action: Git at EclipseHelios in Action: Git at Eclipse
Helios in Action: Git at Eclipse
 
Der Freitag, A Use Case
Der Freitag, A Use CaseDer Freitag, A Use Case
Der Freitag, A Use Case
 
Git tech talk
Git tech talkGit tech talk
Git tech talk
 
Corwin on containers
Corwin on containersCorwin on containers
Corwin on containers
 
Git advanced
Git advancedGit advanced
Git advanced
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Git
 
Git - Drupalcamp Ireland Dublin 2010
Git - Drupalcamp Ireland Dublin 2010Git - Drupalcamp Ireland Dublin 2010
Git - Drupalcamp Ireland Dublin 2010
 
Open source
Open sourceOpen source
Open source
 
Workshop on Source control, git merge walkthroughs
Workshop on Source control, git merge walkthroughsWorkshop on Source control, git merge walkthroughs
Workshop on Source control, git merge walkthroughs
 
Version open source everything
Version   open source everythingVersion   open source everything
Version open source everything
 

Semelhante a Modern source and_version_control_with_git

Git Without Branches - Simple, Smooth, Scalable
Git Without Branches - Simple, Smooth, ScalableGit Without Branches - Simple, Smooth, Scalable
Git Without Branches - Simple, Smooth, Scalable
pieterh
 
Introduction to git and stash
Introduction to git and stashIntroduction to git and stash
Introduction to git and stash
Xpand IT
 
Harvard ABCD-WWW Git presentation
Harvard ABCD-WWW Git presentationHarvard ABCD-WWW Git presentation
Harvard ABCD-WWW Git presentation
Jeff Byrnes
 
3 Git
3 Git3 Git
Beginner walkthrough to git and github
Beginner walkthrough to git and githubBeginner walkthrough to git and github
Beginner walkthrough to git and github
Mahmoud Said
 

Semelhante a Modern source and_version_control_with_git (20)

Git Without Branches - Simple, Smooth, Scalable
Git Without Branches - Simple, Smooth, ScalableGit Without Branches - Simple, Smooth, Scalable
Git Without Branches - Simple, Smooth, Scalable
 
Git flow
Git flowGit flow
Git flow
 
Introduction to git and stash
Introduction to git and stashIntroduction to git and stash
Introduction to git and stash
 
Harvard ABCD-WWW Git presentation
Harvard ABCD-WWW Git presentationHarvard ABCD-WWW Git presentation
Harvard ABCD-WWW Git presentation
 
Git essential training & sharing self
Git essential training & sharing selfGit essential training & sharing self
Git essential training & sharing self
 
Using Git with WordPress - Presented by Nigel Rodgers.
Using Git with WordPress - Presented by Nigel Rodgers.Using Git with WordPress - Presented by Nigel Rodgers.
Using Git with WordPress - Presented by Nigel Rodgers.
 
Managing e commerce systems codebase with git
Managing e commerce systems codebase with gitManaging e commerce systems codebase with git
Managing e commerce systems codebase with git
 
Introduction to git flow
Introduction to git flowIntroduction to git flow
Introduction to git flow
 
3 Git
3 Git3 Git
3 Git
 
Beginner walkthrough to git and github
Beginner walkthrough to git and githubBeginner walkthrough to git and github
Beginner walkthrough to git and github
 
Lets git to it
Lets git to itLets git to it
Lets git to it
 
Git and GitHub workflows
Git and GitHub workflowsGit and GitHub workflows
Git and GitHub workflows
 
Git(hub) for windows developers
Git(hub) for windows developersGit(hub) for windows developers
Git(hub) for windows developers
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Git
 
Git SVN Migrate Reasons
Git SVN Migrate ReasonsGit SVN Migrate Reasons
Git SVN Migrate Reasons
 
Git introduction
Git introductionGit introduction
Git introduction
 
Version Controlling With Git
Version Controlling With GitVersion Controlling With Git
Version Controlling With Git
 
Git Introduction
Git IntroductionGit Introduction
Git Introduction
 
Gitting better
Gitting betterGitting better
Gitting better
 
Brief tutorial on Git
Brief tutorial on GitBrief tutorial on Git
Brief tutorial on Git
 

Último

introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
VishalKumarJha10
 

Último (20)

introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
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
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 
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 🔝✔️✔️
 
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfThe Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
 
BUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptxBUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptx
 
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
 
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
 

Modern source and_version_control_with_git