SlideShare une entreprise Scribd logo
1  sur  8
Télécharger pour lire hors ligne
Learn Version Control with Git
Understanding Branching 

& Merging in Git
The World Without Branches
Login Feature New Design #1 Bugfix #213
C1 C3 C7C5C2 C6C4
CHAOS
What happens if your client doesn’t
like “New Design #1”? How do you
get (only) that code out?
If “Login Feature” introduces a bug,
all of your code contains this bug!
What if you need to release “Login
Feature”? It already contains “New
Design #1” - which you maybe
don’t want to release…
Branches to the Rescue
C1 C5
Login
Feature
New Design #1
Bugfix #213 C4
C3 C7
C2 C6
each topic gets its own context,
completely separated from
any other context
- If something goes wrong, only this context has the problem!
- Creating and deleting contexts is quick & easy!
Pointers and the HEAD
C1
C2
C3
contact-form HEAD
master
branches are just pointers
on commits (no magic…)
at any time point in time,
only one branch can be
active = checked out = HEAD
in Git, you are always
working on a branch!
Switching the Active Branch
the “checkout” command moves the
HEAD pointer to a different branch - 

and thereby makes that branch active
$ git checkout master
C1
C2
C3
contact-form
master HEAD
Switching the Active Branch
to switch the active branch
simply double-click it
in a desktop app like Tower
all local branches are
listed in the sidebar
Merging Branches
$ git merge contact-form
merging integrates all the commits
(the ones you don’t have, yet) from the
specified branch into your current HEAD
C1
C2 contact-form
master HEAD
C3
C4
merge commit
C5
Learn Git with our free online book on
www.git-tower.com/learn

Contenu connexe

Tendances

Git Series. Episode 3. Git Flow and Github-Flow
Git Series. Episode 3. Git Flow and Github-FlowGit Series. Episode 3. Git Flow and Github-Flow
Git Series. Episode 3. Git Flow and Github-FlowMikhail Melnik
 
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
 
Git and git workflow best practice
Git and git workflow best practiceGit and git workflow best practice
Git and git workflow best practiceMajid Hosseini
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to GitLukas Fittl
 
Git One Day Training Notes
Git One Day Training NotesGit One Day Training Notes
Git One Day Training Notesglen_a_smith
 
Git Introduction Tutorial
Git Introduction TutorialGit Introduction Tutorial
Git Introduction TutorialThomas Rausch
 
Git branching strategies
Git branching strategiesGit branching strategies
Git branching strategiesjstack
 
Intro to git and git hub
Intro to git and git hubIntro to git and git hub
Intro to git and git hubVenkat Malladi
 
Git and GitFlow branching model
Git and GitFlow branching modelGit and GitFlow branching model
Git and GitFlow branching modelPavlo Hodysh
 
Git Branching for Agile Teams
Git Branching for Agile Teams Git Branching for Agile Teams
Git Branching for Agile Teams Atlassian
 
Learning git
Learning gitLearning git
Learning gitSid Anand
 

Tendances (20)

Git Series. Episode 3. Git Flow and Github-Flow
Git Series. Episode 3. Git Flow and Github-FlowGit Series. Episode 3. Git Flow and Github-Flow
Git Series. Episode 3. Git Flow and Github-Flow
 
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
 
Git and git workflow best practice
Git and git workflow best practiceGit and git workflow best practice
Git and git workflow best practice
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Git
 
Git One Day Training Notes
Git One Day Training NotesGit One Day Training Notes
Git One Day Training Notes
 
Git Rebase vs Merge
Git Rebase vs MergeGit Rebase vs Merge
Git Rebase vs Merge
 
Git and github 101
Git and github 101Git and github 101
Git and github 101
 
Git 101 for Beginners
Git 101 for Beginners Git 101 for Beginners
Git 101 for Beginners
 
Git Pull Requests
Git Pull RequestsGit Pull Requests
Git Pull Requests
 
Git Introduction Tutorial
Git Introduction TutorialGit Introduction Tutorial
Git Introduction Tutorial
 
Git branching strategies
Git branching strategiesGit branching strategies
Git branching strategies
 
Intro to git and git hub
Intro to git and git hubIntro to git and git hub
Intro to git and git hub
 
Introduction git
Introduction gitIntroduction git
Introduction git
 
Git and GitFlow branching model
Git and GitFlow branching modelGit and GitFlow branching model
Git and GitFlow branching model
 
Git Branching for Agile Teams
Git Branching for Agile Teams Git Branching for Agile Teams
Git Branching for Agile Teams
 
Git best practices workshop
Git best practices workshopGit best practices workshop
Git best practices workshop
 
Introducing GitLab
Introducing GitLabIntroducing GitLab
Introducing GitLab
 
Learning git
Learning gitLearning git
Learning git
 
Git Branching Model
Git Branching ModelGit Branching Model
Git Branching Model
 
Git advanced
Git advancedGit advanced
Git advanced
 

Similaire à Understanding Branching and Merging in Git

Clarive 7 Branching Model
Clarive 7 Branching ModelClarive 7 Branching Model
Clarive 7 Branching ModelClarive
 
How We Use GitHub
How We Use GitHubHow We Use GitHub
How We Use GitHubNYC DevShop
 
Git Merge, Resets and Branches
Git Merge, Resets and BranchesGit Merge, Resets and Branches
Git Merge, Resets and BranchesVictor Pudelski
 
HTML5 Is the Future of Book Authorship
HTML5 Is the Future of Book AuthorshipHTML5 Is the Future of Book Authorship
HTML5 Is the Future of Book AuthorshipSanders Kleinfeld
 
3DC Intro to Git Workshop
3DC Intro to Git Workshop3DC Intro to Git Workshop
3DC Intro to Git WorkshopBeckhamWee
 
The right tools for the right job (or: surviving Magento 2 coding)
The right tools for the right job (or: surviving Magento 2 coding)The right tools for the right job (or: surviving Magento 2 coding)
The right tools for the right job (or: surviving Magento 2 coding)MageSpecialist
 
CoDe:U git flow
CoDe:U git flowCoDe:U git flow
CoDe:U git flowLars Kruse
 
A Git MVP Workflow
A Git MVP WorkflowA Git MVP Workflow
A Git MVP WorkflowBurt Lum
 
How to write good quality code
How to write good quality codeHow to write good quality code
How to write good quality codeHayden Bleasel
 
Git - Simplified For Testers
Git - Simplified For TestersGit - Simplified For Testers
Git - Simplified For Testersupadhyay_25
 
Vincit Teatime 2015.2 - Otto Kekäläinen: Don't be a git
Vincit Teatime 2015.2 - Otto Kekäläinen: Don't be a gitVincit Teatime 2015.2 - Otto Kekäläinen: Don't be a git
Vincit Teatime 2015.2 - Otto Kekäläinen: Don't be a gitVincitOy
 
Case Study: How did we reduce the build time to one fifth?
Case Study: How did we reduce the build time to one fifth?Case Study: How did we reduce the build time to one fifth?
Case Study: How did we reduce the build time to one fifth?Péter Takács
 
AgileMaturityIncludesContinuousIntegrationContinuousDeployment
AgileMaturityIncludesContinuousIntegrationContinuousDeployment AgileMaturityIncludesContinuousIntegrationContinuousDeployment
AgileMaturityIncludesContinuousIntegrationContinuousDeployment Jack Wendel
 
Old code doesn't stink - Detroit
Old code doesn't stink - DetroitOld code doesn't stink - Detroit
Old code doesn't stink - DetroitMartin Gutenbrunner
 
Makin’ chatbots – Moment
Makin’ chatbots – MomentMakin’ chatbots – Moment
Makin’ chatbots – Momentjacobpastrovich
 
Trunk Based Development in the Enterprise - Its Relevance and Economics
Trunk Based Development in the Enterprise - Its Relevance and EconomicsTrunk Based Development in the Enterprise - Its Relevance and Economics
Trunk Based Development in the Enterprise - Its Relevance and EconomicsPerforce
 

Similaire à Understanding Branching and Merging in Git (20)

Clarive 7 Branching Model
Clarive 7 Branching ModelClarive 7 Branching Model
Clarive 7 Branching Model
 
How We Use GitHub
How We Use GitHubHow We Use GitHub
How We Use GitHub
 
Git Merge, Resets and Branches
Git Merge, Resets and BranchesGit Merge, Resets and Branches
Git Merge, Resets and Branches
 
HTML5 Is the Future of Book Authorship
HTML5 Is the Future of Book AuthorshipHTML5 Is the Future of Book Authorship
HTML5 Is the Future of Book Authorship
 
3DC Intro to Git Workshop
3DC Intro to Git Workshop3DC Intro to Git Workshop
3DC Intro to Git Workshop
 
Git & Code review
Git & Code reviewGit & Code review
Git & Code review
 
The right tools for the right job (or: surviving Magento 2 coding)
The right tools for the right job (or: surviving Magento 2 coding)The right tools for the right job (or: surviving Magento 2 coding)
The right tools for the right job (or: surviving Magento 2 coding)
 
CoDe:U git flow
CoDe:U git flowCoDe:U git flow
CoDe:U git flow
 
A Git MVP Workflow
A Git MVP WorkflowA Git MVP Workflow
A Git MVP Workflow
 
Git workflows
Git workflowsGit workflows
Git workflows
 
How to write good quality code
How to write good quality codeHow to write good quality code
How to write good quality code
 
Git - Simplified For Testers
Git - Simplified For TestersGit - Simplified For Testers
Git - Simplified For Testers
 
Git essentials
Git essentialsGit essentials
Git essentials
 
Vincit Teatime 2015.2 - Otto Kekäläinen: Don't be a git
Vincit Teatime 2015.2 - Otto Kekäläinen: Don't be a gitVincit Teatime 2015.2 - Otto Kekäläinen: Don't be a git
Vincit Teatime 2015.2 - Otto Kekäläinen: Don't be a git
 
Case Study: How did we reduce the build time to one fifth?
Case Study: How did we reduce the build time to one fifth?Case Study: How did we reduce the build time to one fifth?
Case Study: How did we reduce the build time to one fifth?
 
AgileMaturityIncludesContinuousIntegrationContinuousDeployment
AgileMaturityIncludesContinuousIntegrationContinuousDeployment AgileMaturityIncludesContinuousIntegrationContinuousDeployment
AgileMaturityIncludesContinuousIntegrationContinuousDeployment
 
Old code doesn't stink - Detroit
Old code doesn't stink - DetroitOld code doesn't stink - Detroit
Old code doesn't stink - Detroit
 
Introduction to Git (part 3)
Introduction to Git (part 3)Introduction to Git (part 3)
Introduction to Git (part 3)
 
Makin’ chatbots – Moment
Makin’ chatbots – MomentMakin’ chatbots – Moment
Makin’ chatbots – Moment
 
Trunk Based Development in the Enterprise - Its Relevance and Economics
Trunk Based Development in the Enterprise - Its Relevance and EconomicsTrunk Based Development in the Enterprise - Its Relevance and Economics
Trunk Based Development in the Enterprise - Its Relevance and Economics
 

Dernier

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 GoalsJhone kinadey
 
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...masabamasaba
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfonteinmasabamasaba
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrainmasabamasaba
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...Shane Coughlan
 
%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 tembisamasabamasaba
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastPapp Krisztián
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park masabamasaba
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...masabamasaba
 
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 ...Nitya salvi
 
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.pdfproinshot.com
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionOnePlan Solutions
 
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 studentsHimanshiGarg82
 
SHRMPro HRMS Software Solutions Presentation
SHRMPro HRMS Software Solutions PresentationSHRMPro HRMS Software Solutions Presentation
SHRMPro HRMS Software Solutions PresentationShrmpro
 
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.pdfkalichargn70th171
 
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 .pdfayushiqss
 
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.pdfVishalKumarJha10
 

Dernier (20)

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
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
%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
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
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 ...
 
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
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
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
 
SHRMPro HRMS Software Solutions Presentation
SHRMPro HRMS Software Solutions PresentationSHRMPro HRMS Software Solutions Presentation
SHRMPro HRMS Software Solutions Presentation
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.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
 
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
 
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
 

Understanding Branching and Merging in Git

  • 1. Learn Version Control with Git Understanding Branching 
 & Merging in Git
  • 2. The World Without Branches Login Feature New Design #1 Bugfix #213 C1 C3 C7C5C2 C6C4 CHAOS What happens if your client doesn’t like “New Design #1”? How do you get (only) that code out? If “Login Feature” introduces a bug, all of your code contains this bug! What if you need to release “Login Feature”? It already contains “New Design #1” - which you maybe don’t want to release…
  • 3. Branches to the Rescue C1 C5 Login Feature New Design #1 Bugfix #213 C4 C3 C7 C2 C6 each topic gets its own context, completely separated from any other context - If something goes wrong, only this context has the problem! - Creating and deleting contexts is quick & easy!
  • 4. Pointers and the HEAD C1 C2 C3 contact-form HEAD master branches are just pointers on commits (no magic…) at any time point in time, only one branch can be active = checked out = HEAD in Git, you are always working on a branch!
  • 5. Switching the Active Branch the “checkout” command moves the HEAD pointer to a different branch - 
 and thereby makes that branch active $ git checkout master C1 C2 C3 contact-form master HEAD
  • 6. Switching the Active Branch to switch the active branch simply double-click it in a desktop app like Tower all local branches are listed in the sidebar
  • 7. Merging Branches $ git merge contact-form merging integrates all the commits (the ones you don’t have, yet) from the specified branch into your current HEAD C1 C2 contact-form master HEAD C3 C4 merge commit C5
  • 8. Learn Git with our free online book on www.git-tower.com/learn