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
Ad

More Related Content

What's hot (20)

Git commands
Git commandsGit commands
Git commands
Viyaan Jhiingade
 
Intro to git and git hub
Intro to git and git hubIntro to git and git hub
Intro to git and git hub
Venkat Malladi
 
Learning git
Learning gitLearning git
Learning git
Sid Anand
 
Git basics
Git basicsGit basics
Git basics
GHARSALLAH Mohamed
 
Git Introduction Tutorial
Git Introduction TutorialGit Introduction Tutorial
Git Introduction Tutorial
Thomas Rausch
 
GIT presentation
GIT presentationGIT presentation
GIT presentation
Naim Latifi
 
Git best practices workshop
Git best practices workshopGit best practices workshop
Git best practices workshop
Otto Kekäläinen
 
Introduction git
Introduction gitIntroduction git
Introduction git
Dian Sigit Prastowo
 
Git branching strategies
Git branching strategiesGit branching strategies
Git branching strategies
jstack
 
Git in 10 minutes
Git in 10 minutesGit in 10 minutes
Git in 10 minutes
Safique Ahmed Faruque
 
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
Mikhail Melnik
 
Git advanced
Git advancedGit advanced
Git advanced
Peter Vandenabeele
 
Git and Github Session
Git and Github SessionGit and Github Session
Git and Github Session
GoogleDevelopersStud1
 
Git - An Introduction
Git - An IntroductionGit - An Introduction
Git - An Introduction
Behzad Altaf
 
Grokking opensource with github
Grokking opensource with githubGrokking opensource with github
Grokking opensource with github
GoogleDeveloperStude4
 
Git real slides
Git real slidesGit real slides
Git real slides
Lucas Couto
 
Git Branching and Merging.pptx
Git Branching and Merging.pptxGit Branching and Merging.pptx
Git Branching and Merging.pptx
tapanvyas11
 
Git and GitHub workflows
Git and GitHub workflowsGit and GitHub workflows
Git and GitHub workflows
Arthur Shvetsov
 
git and github
git and githubgit and github
git and github
Darren Oakley
 
Introduction To Git
Introduction To GitIntroduction To Git
Introduction To Git
Arnaud Seilles
 

Similar to Understanding Branching and Merging in Git (20)

Clarive 7 Branching Model
Clarive 7 Branching ModelClarive 7 Branching Model
Clarive 7 Branching Model
Clarive
 
How We Use GitHub
How We Use GitHubHow We Use GitHub
How We Use GitHub
NYC DevShop
 
Git Merge, Resets and Branches
Git Merge, Resets and BranchesGit Merge, Resets and Branches
Git Merge, Resets and Branches
Victor 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 Authorship
Sanders Kleinfeld
 
3DC Intro to Git Workshop
3DC Intro to Git Workshop3DC Intro to Git Workshop
3DC Intro to Git Workshop
BeckhamWee
 
Git & Code review
Git & Code reviewGit & Code review
Git & Code review
Cenk Gültekin
 
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 flow
Lars Kruse
 
A Git MVP Workflow
A Git MVP WorkflowA Git MVP Workflow
A Git MVP Workflow
Burt Lum
 
Git workflows
Git workflowsGit workflows
Git workflows
Thuc Le Dong
 
How to write good quality code
How to write good quality codeHow to write good quality code
How to write good quality code
Hayden Bleasel
 
Git - Simplified For Testers
Git - Simplified For TestersGit - Simplified For Testers
Git - Simplified For Testers
upadhyay_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 git
VincitOy
 
Git essentials
Git essentialsGit essentials
Git essentials
Otto Kekäläinen
 
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 - Detroit
Martin Gutenbrunner
 
Introduction to Git (part 3)
Introduction to Git (part 3)Introduction to Git (part 3)
Introduction to Git (part 3)
Salvatore Cordiano
 
Makin’ chatbots – Moment
Makin’ chatbots – MomentMakin’ chatbots – Moment
Makin’ chatbots – Moment
jacobpastrovich
 
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
Perforce
 
Clarive 7 Branching Model
Clarive 7 Branching ModelClarive 7 Branching Model
Clarive 7 Branching Model
Clarive
 
How We Use GitHub
How We Use GitHubHow We Use GitHub
How We Use GitHub
NYC DevShop
 
Git Merge, Resets and Branches
Git Merge, Resets and BranchesGit Merge, Resets and Branches
Git Merge, Resets and Branches
Victor 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 Authorship
Sanders Kleinfeld
 
3DC Intro to Git Workshop
3DC Intro to Git Workshop3DC Intro to Git Workshop
3DC Intro to Git Workshop
BeckhamWee
 
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 flow
Lars Kruse
 
A Git MVP Workflow
A Git MVP WorkflowA Git MVP Workflow
A Git MVP Workflow
Burt Lum
 
How to write good quality code
How to write good quality codeHow to write good quality code
How to write good quality code
Hayden Bleasel
 
Git - Simplified For Testers
Git - Simplified For TestersGit - Simplified For Testers
Git - Simplified For Testers
upadhyay_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 git
VincitOy
 
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 - Detroit
Martin Gutenbrunner
 
Makin’ chatbots – Moment
Makin’ chatbots – MomentMakin’ chatbots – Moment
Makin’ chatbots – Moment
jacobpastrovich
 
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
Perforce
 
Ad

Recently uploaded (20)

Requirements in Engineering AI- Enabled Systems: Open Problems and Safe AI Sy...
Requirements in Engineering AI- Enabled Systems: Open Problems and Safe AI Sy...Requirements in Engineering AI- Enabled Systems: Open Problems and Safe AI Sy...
Requirements in Engineering AI- Enabled Systems: Open Problems and Safe AI Sy...
Lionel Briand
 
Pixologic ZBrush Crack Plus Activation Key [Latest 2025] New Version
Pixologic ZBrush Crack Plus Activation Key [Latest 2025] New VersionPixologic ZBrush Crack Plus Activation Key [Latest 2025] New Version
Pixologic ZBrush Crack Plus Activation Key [Latest 2025] New Version
saimabibi60507
 
Landscape of Requirements Engineering for/by AI through Literature Review
Landscape of Requirements Engineering for/by AI through Literature ReviewLandscape of Requirements Engineering for/by AI through Literature Review
Landscape of Requirements Engineering for/by AI through Literature Review
Hironori Washizaki
 
Why Orangescrum Is a Game Changer for Construction Companies in 2025
Why Orangescrum Is a Game Changer for Construction Companies in 2025Why Orangescrum Is a Game Changer for Construction Companies in 2025
Why Orangescrum Is a Game Changer for Construction Companies in 2025
Orangescrum
 
Expand your AI adoption with AgentExchange
Expand your AI adoption with AgentExchangeExpand your AI adoption with AgentExchange
Expand your AI adoption with AgentExchange
Fexle Services Pvt. Ltd.
 
Designing AI-Powered APIs on Azure: Best Practices& Considerations
Designing AI-Powered APIs on Azure: Best Practices& ConsiderationsDesigning AI-Powered APIs on Azure: Best Practices& Considerations
Designing AI-Powered APIs on Azure: Best Practices& Considerations
Dinusha Kumarasiri
 
Download Wondershare Filmora Crack [2025] With Latest
Download Wondershare Filmora Crack [2025] With LatestDownload Wondershare Filmora Crack [2025] With Latest
Download Wondershare Filmora Crack [2025] With Latest
tahirabibi60507
 
Explaining GitHub Actions Failures with Large Language Models Challenges, In...
Explaining GitHub Actions Failures with Large Language Models Challenges, In...Explaining GitHub Actions Failures with Large Language Models Challenges, In...
Explaining GitHub Actions Failures with Large Language Models Challenges, In...
ssuserb14185
 
WinRAR Crack for Windows (100% Working 2025)
WinRAR Crack for Windows (100% Working 2025)WinRAR Crack for Windows (100% Working 2025)
WinRAR Crack for Windows (100% Working 2025)
sh607827
 
Adobe Master Collection CC Crack Advance Version 2025
Adobe Master Collection CC Crack Advance Version 2025Adobe Master Collection CC Crack Advance Version 2025
Adobe Master Collection CC Crack Advance Version 2025
kashifyounis067
 
Kubernetes_101_Zero_to_Platform_Engineer.pptx
Kubernetes_101_Zero_to_Platform_Engineer.pptxKubernetes_101_Zero_to_Platform_Engineer.pptx
Kubernetes_101_Zero_to_Platform_Engineer.pptx
CloudScouts
 
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Andre Hora
 
Top 10 Client Portal Software Solutions for 2025.docx
Top 10 Client Portal Software Solutions for 2025.docxTop 10 Client Portal Software Solutions for 2025.docx
Top 10 Client Portal Software Solutions for 2025.docx
Portli
 
Secure Test Infrastructure: The Backbone of Trustworthy Software Development
Secure Test Infrastructure: The Backbone of Trustworthy Software DevelopmentSecure Test Infrastructure: The Backbone of Trustworthy Software Development
Secure Test Infrastructure: The Backbone of Trustworthy Software Development
Shubham Joshi
 
Avast Premium Security Crack FREE Latest Version 2025
Avast Premium Security Crack FREE Latest Version 2025Avast Premium Security Crack FREE Latest Version 2025
Avast Premium Security Crack FREE Latest Version 2025
mu394968
 
Adobe Illustrator Crack FREE Download 2025 Latest Version
Adobe Illustrator Crack FREE Download 2025 Latest VersionAdobe Illustrator Crack FREE Download 2025 Latest Version
Adobe Illustrator Crack FREE Download 2025 Latest Version
kashifyounis067
 
Scaling GraphRAG: Efficient Knowledge Retrieval for Enterprise AI
Scaling GraphRAG:  Efficient Knowledge Retrieval for Enterprise AIScaling GraphRAG:  Efficient Knowledge Retrieval for Enterprise AI
Scaling GraphRAG: Efficient Knowledge Retrieval for Enterprise AI
danshalev
 
Who Watches the Watchmen (SciFiDevCon 2025)
Who Watches the Watchmen (SciFiDevCon 2025)Who Watches the Watchmen (SciFiDevCon 2025)
Who Watches the Watchmen (SciFiDevCon 2025)
Allon Mureinik
 
Revolutionizing Residential Wi-Fi PPT.pptx
Revolutionizing Residential Wi-Fi PPT.pptxRevolutionizing Residential Wi-Fi PPT.pptx
Revolutionizing Residential Wi-Fi PPT.pptx
nidhisingh691197
 
The Significance of Hardware in Information Systems.pdf
The Significance of Hardware in Information Systems.pdfThe Significance of Hardware in Information Systems.pdf
The Significance of Hardware in Information Systems.pdf
drewplanas10
 
Requirements in Engineering AI- Enabled Systems: Open Problems and Safe AI Sy...
Requirements in Engineering AI- Enabled Systems: Open Problems and Safe AI Sy...Requirements in Engineering AI- Enabled Systems: Open Problems and Safe AI Sy...
Requirements in Engineering AI- Enabled Systems: Open Problems and Safe AI Sy...
Lionel Briand
 
Pixologic ZBrush Crack Plus Activation Key [Latest 2025] New Version
Pixologic ZBrush Crack Plus Activation Key [Latest 2025] New VersionPixologic ZBrush Crack Plus Activation Key [Latest 2025] New Version
Pixologic ZBrush Crack Plus Activation Key [Latest 2025] New Version
saimabibi60507
 
Landscape of Requirements Engineering for/by AI through Literature Review
Landscape of Requirements Engineering for/by AI through Literature ReviewLandscape of Requirements Engineering for/by AI through Literature Review
Landscape of Requirements Engineering for/by AI through Literature Review
Hironori Washizaki
 
Why Orangescrum Is a Game Changer for Construction Companies in 2025
Why Orangescrum Is a Game Changer for Construction Companies in 2025Why Orangescrum Is a Game Changer for Construction Companies in 2025
Why Orangescrum Is a Game Changer for Construction Companies in 2025
Orangescrum
 
Expand your AI adoption with AgentExchange
Expand your AI adoption with AgentExchangeExpand your AI adoption with AgentExchange
Expand your AI adoption with AgentExchange
Fexle Services Pvt. Ltd.
 
Designing AI-Powered APIs on Azure: Best Practices& Considerations
Designing AI-Powered APIs on Azure: Best Practices& ConsiderationsDesigning AI-Powered APIs on Azure: Best Practices& Considerations
Designing AI-Powered APIs on Azure: Best Practices& Considerations
Dinusha Kumarasiri
 
Download Wondershare Filmora Crack [2025] With Latest
Download Wondershare Filmora Crack [2025] With LatestDownload Wondershare Filmora Crack [2025] With Latest
Download Wondershare Filmora Crack [2025] With Latest
tahirabibi60507
 
Explaining GitHub Actions Failures with Large Language Models Challenges, In...
Explaining GitHub Actions Failures with Large Language Models Challenges, In...Explaining GitHub Actions Failures with Large Language Models Challenges, In...
Explaining GitHub Actions Failures with Large Language Models Challenges, In...
ssuserb14185
 
WinRAR Crack for Windows (100% Working 2025)
WinRAR Crack for Windows (100% Working 2025)WinRAR Crack for Windows (100% Working 2025)
WinRAR Crack for Windows (100% Working 2025)
sh607827
 
Adobe Master Collection CC Crack Advance Version 2025
Adobe Master Collection CC Crack Advance Version 2025Adobe Master Collection CC Crack Advance Version 2025
Adobe Master Collection CC Crack Advance Version 2025
kashifyounis067
 
Kubernetes_101_Zero_to_Platform_Engineer.pptx
Kubernetes_101_Zero_to_Platform_Engineer.pptxKubernetes_101_Zero_to_Platform_Engineer.pptx
Kubernetes_101_Zero_to_Platform_Engineer.pptx
CloudScouts
 
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Exceptional Behaviors: How Frequently Are They Tested? (AST 2025)
Andre Hora
 
Top 10 Client Portal Software Solutions for 2025.docx
Top 10 Client Portal Software Solutions for 2025.docxTop 10 Client Portal Software Solutions for 2025.docx
Top 10 Client Portal Software Solutions for 2025.docx
Portli
 
Secure Test Infrastructure: The Backbone of Trustworthy Software Development
Secure Test Infrastructure: The Backbone of Trustworthy Software DevelopmentSecure Test Infrastructure: The Backbone of Trustworthy Software Development
Secure Test Infrastructure: The Backbone of Trustworthy Software Development
Shubham Joshi
 
Avast Premium Security Crack FREE Latest Version 2025
Avast Premium Security Crack FREE Latest Version 2025Avast Premium Security Crack FREE Latest Version 2025
Avast Premium Security Crack FREE Latest Version 2025
mu394968
 
Adobe Illustrator Crack FREE Download 2025 Latest Version
Adobe Illustrator Crack FREE Download 2025 Latest VersionAdobe Illustrator Crack FREE Download 2025 Latest Version
Adobe Illustrator Crack FREE Download 2025 Latest Version
kashifyounis067
 
Scaling GraphRAG: Efficient Knowledge Retrieval for Enterprise AI
Scaling GraphRAG:  Efficient Knowledge Retrieval for Enterprise AIScaling GraphRAG:  Efficient Knowledge Retrieval for Enterprise AI
Scaling GraphRAG: Efficient Knowledge Retrieval for Enterprise AI
danshalev
 
Who Watches the Watchmen (SciFiDevCon 2025)
Who Watches the Watchmen (SciFiDevCon 2025)Who Watches the Watchmen (SciFiDevCon 2025)
Who Watches the Watchmen (SciFiDevCon 2025)
Allon Mureinik
 
Revolutionizing Residential Wi-Fi PPT.pptx
Revolutionizing Residential Wi-Fi PPT.pptxRevolutionizing Residential Wi-Fi PPT.pptx
Revolutionizing Residential Wi-Fi PPT.pptx
nidhisingh691197
 
The Significance of Hardware in Information Systems.pdf
The Significance of Hardware in Information Systems.pdfThe Significance of Hardware in Information Systems.pdf
The Significance of Hardware in Information Systems.pdf
drewplanas10
 
Ad

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