SlideShare a Scribd company logo
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

More Related Content

What's hot

Git workflows
Git workflowsGit workflows
Git workflows
Xpand IT
 
Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...
Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...
Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...
Simplilearn
 

What's hot (20)

Git and git flow
Git and git flowGit and git flow
Git and git flow
 
Git-flow workflow and pull-requests
Git-flow workflow and pull-requestsGit-flow workflow and pull-requests
Git-flow workflow and pull-requests
 
Git basics
Git basicsGit basics
Git basics
 
Git branching strategies
Git branching strategiesGit branching strategies
Git branching strategies
 
Introduction git
Introduction gitIntroduction git
Introduction git
 
Git workflows
Git workflowsGit workflows
Git workflows
 
Basic Git Intro
Basic Git IntroBasic Git Intro
Basic Git Intro
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Git
 
git and github
git and githubgit and github
git and github
 
Git Branching Model
Git Branching ModelGit Branching Model
Git Branching Model
 
Git real slides
Git real slidesGit real slides
Git real slides
 
Git
GitGit
Git
 
Git Rebase vs Merge
Git Rebase vs MergeGit Rebase vs Merge
Git Rebase vs Merge
 
Git One Day Training Notes
Git One Day Training NotesGit One Day Training Notes
Git One Day Training Notes
 
Git and github 101
Git and github 101Git and github 101
Git and github 101
 
GIT presentation
GIT presentationGIT presentation
GIT presentation
 
Introduction to github slideshare
Introduction to github slideshareIntroduction to github slideshare
Introduction to github slideshare
 
Getting Git Right
Getting Git RightGetting Git Right
Getting Git Right
 
Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...
Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...
Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...
 
Intro to git and git hub
Intro to git and git hubIntro to git and git hub
Intro to git and git hub
 

Similar to Understanding Branching and Merging in Git

Git - Simplified For Testers
Git - Simplified For TestersGit - Simplified For Testers
Git - Simplified For Testers
upadhyay_25
 
AgileMaturityIncludesContinuousIntegrationContinuousDeployment
AgileMaturityIncludesContinuousIntegrationContinuousDeployment AgileMaturityIncludesContinuousIntegrationContinuousDeployment
AgileMaturityIncludesContinuousIntegrationContinuousDeployment
Jack Wendel
 

Similar to 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
 

Recently uploaded

Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns
 
Mastering Windows 7 A Comprehensive Guide for Power Users .pdf
Mastering Windows 7 A Comprehensive Guide for Power Users .pdfMastering Windows 7 A Comprehensive Guide for Power Users .pdf
Mastering Windows 7 A Comprehensive Guide for Power Users .pdf
mbmh111980
 

Recently uploaded (20)

AI/ML Infra Meetup | Perspective on Deep Learning Framework
AI/ML Infra Meetup | Perspective on Deep Learning FrameworkAI/ML Infra Meetup | Perspective on Deep Learning Framework
AI/ML Infra Meetup | Perspective on Deep Learning Framework
 
A Python-based approach to data loading in TM1 - Using Airflow as an ETL for TM1
A Python-based approach to data loading in TM1 - Using Airflow as an ETL for TM1A Python-based approach to data loading in TM1 - Using Airflow as an ETL for TM1
A Python-based approach to data loading in TM1 - Using Airflow as an ETL for TM1
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
 
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
 
GraphAware - Transforming policing with graph-based intelligence analysis
GraphAware - Transforming policing with graph-based intelligence analysisGraphAware - Transforming policing with graph-based intelligence analysis
GraphAware - Transforming policing with graph-based intelligence analysis
 
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAGAI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
Field Employee Tracking System| MiTrack App| Best Employee Tracking Solution|...
 
Mastering Windows 7 A Comprehensive Guide for Power Users .pdf
Mastering Windows 7 A Comprehensive Guide for Power Users .pdfMastering Windows 7 A Comprehensive Guide for Power Users .pdf
Mastering Windows 7 A Comprehensive Guide for Power Users .pdf
 
Breaking the Code : A Guide to WhatsApp Business API.pdf
Breaking the Code : A Guide to WhatsApp Business API.pdfBreaking the Code : A Guide to WhatsApp Business API.pdf
Breaking the Code : A Guide to WhatsApp Business API.pdf
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
 
Designing for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web ServicesDesigning for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web Services
 
Corporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMSCorporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMS
 
De mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FMEDe mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FME
 
Accelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with PlatformlessAccelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with Platformless
 
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
 
AI/ML Infra Meetup | ML explainability in Michelangelo
AI/ML Infra Meetup | ML explainability in MichelangeloAI/ML Infra Meetup | ML explainability in Michelangelo
AI/ML Infra Meetup | ML explainability in Michelangelo
 
top nidhi software solution freedownload
top nidhi software solution freedownloadtop nidhi software solution freedownload
top nidhi software solution freedownload
 
iGaming Platform & Lottery Solutions by Skilrock
iGaming Platform & Lottery Solutions by SkilrockiGaming Platform & Lottery Solutions by Skilrock
iGaming Platform & Lottery Solutions by Skilrock
 

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