SlideShare a Scribd company logo
1 of 21
Gitflow
By Maulik Shah
Types of VCS & Difference Between Them
Centralized DeCentralized
As a consequence of its simplicity and repetitive nature, branching and merging are no longer something
to be afraid of. Version control tools are supposed to assist in branching/merging more than anything
else.
Main Concept
• Each developer pulls and pushes
to origin
• But besides the centralized push-
pull relationships, each developer
may also pull changes from other
peers to form sub teams.
Develop and Master Branches
• Master
• We consider origin/master to be the main branch where the source
code of HEAD always reflects a production-ready state.
• Develop
• We consider origin/develop to be the main branch where the
source code of HEAD always reflects a state with the latest
delivered development changes for the next release.
git branch develop
git push -u origin develop
Supporting branches
• Feature branches
• Release branches
• Hotfix branches
Our development model uses a variety of supporting branches to aid
parallel development between team members, ease tracking of features,
prepare for production releases and to assist in quickly fixing live
production problems. Unlike the main branches, these branches always
have a limited life time, since they will be removed eventually.
Feature(Topic) branches
• May branch off from:
• develop
• Must merge back into:
• develop
• Branch naming convention:
• anything except master, develop, release-*, or hotfix-*
Feature branches (or sometimes called topic branches) are used to develop
new features for the upcoming or a distant future release. When starting
development of a feature, the target release in which this feature will be
incorporated may well be unknown at that point. The essence of a feature
branch is that it exists as long as the feature is in development, but will
eventually be merged back into develop (to definitely add the new feature to
the upcoming release) or discarded (in case of a disappointing experiment).
Creating a feature branch
• When starting work on a new feature, branch off from the develop
branch.
git checkout -b myfeature develop
Incorporating a finished feature on
develop
• Finished features may be merged into the develop branch to
definitely add them to the upcoming release:
$ git checkout develop
Switched to branch 'develop’
$ git merge --no-ff myfeature
Updating ea1b82a..05e9557
(Summary of changes)
$ git branch -d myfeature
Deleted branch myfeature (was 05e9557).
$ git push origin develop
--no-ff
• The --no-ff flag causes the merge to always
create a new commit object, even if the
merge could be performed with a fast-
forward. This avoids losing information about
the historical existence of a feature branch
and groups together all commits that together
added the feature. Compare:
• In the latter case, it is impossible to see from
the Git history which of the commit objects
together have implemented a feature—you
would have to manually read all the log
messages. Reverting a whole feature (i.e. a
group of commits), is a true headache in the
latter situation, whereas it is easily done if
the --no-ff flag was used.
Release branches
• May branch off from:
• develop
• Must merge back into:
• develop and master
• Branch naming convention:
• release-*
• meta-data for a release
Creating a release branch
$ git checkout -b release-1.2 develop
Switched to a new branch "release-1.2"
$ ./bump-version.sh 1.2
Files modified successfully, version bumped to 1.2.
$ git commit -a -m "Bumped version number to 1.2"
[release-1.2 74d9424] Bumped version number to 1.2
1 files changed, 1 insertions(+), 1 deletions(-)
Finishing a release branch- Step1
$ git checkout master
Switched to branch 'master’
$ git merge --no-ff release-1.2
Merge made by recursive.
(Summary of changes)
$ git tag -a 1.2
Finishing a release branch- Step2
• To keep the changes made in the release branch, we need to
merge those back into develop, though. In Git:
$ git checkout develop
Switched to branch 'develop’
$ git merge --no-ff release-1.2
Merge made by recursive.
(Summary of changes)
Finishing a release branch- Step3
• This step may well lead to a merge conflict (probably even, since
we have changed the version number). If so, fix it and commit.
• Now we are really done and the release branch may be removed,
since we don’t need it anymore:
•
$ git branch -d release-1.2
Deleted branch release-1.2 (was ff452fe).
Hotfix branches
• May branch off from:
• master
• Must merge back into:
• develop and master
• Branch naming convention:
• hotfix-*
Creating a hotfix branch Step-1
• Hotfix branches are created from the master branch. For example, say version
1.2 is the current production release running live and causing troubles due to a
severe bug. But changes on develop are yet unstable. We may then branch off a
hotfix branch and start fixing the problem:
$ git checkout -b hotfix-1.2.1 master
Switched to a new branch "hotfix-1.2.1“
$ ./bump-version.sh 1.2.1
Files modified successfully, version bumped to 1.2.1.
$ git commit -a -m "Bumped version number to 1.2.1"
[hotfix-1.2.1 41e61bb] Bumped version number to 1.2.1
1 files changed, 1 insertions(+), 1 deletions(-)
Creating a hotfix branch Step-2
• Then, fix the bug and commit the fix in one or more separate
commits.
$ git commit -m "Fixed severe production problem"
[hotfix-1.2.1 abbe5d6] Fixed severe production problem
5 files changed, 32 insertions(+), 17 deletions(-)
Finishing a hotfix branch- Step1
• First, update master and tag the release.
$ git checkout master
Switched to branch 'master’
$ git merge --no-ff hotfix-1.2.1
Merge made by recursive.
(Summary of changes)
$ git tag -a 1.2.1
Finishing a hotfix branch- Step2
• Next, include the bugfix in develop, too:
$ git checkout develop
Switched to branch 'develop’
$ git merge --no-ff hotfix-1.2.1
Merge made by recursive.
(Summary of changes)
Finishing a hotfix branch- Step3
• Finally, remove the temporary branch:
•
$ git branch -d hotfix-1.2.1
Deleted branch hotfix-1.2.1 (was abbe5d6).
$ git branch -d hotfix-1.2.1 Deleted branch hotfix-1.2.1 (was abbe5d6).
Summary
• While there is nothing really shocking new to this branching
model, the “big picture” figure that this post began with has
turned out to be tremendously useful in our projects. It forms an
elegant mental model that is easy to comprehend and allows team
members to develop a shared understanding of the branching and
releasing processes.
• Reference - https://nvie.com/posts/a-successful-git-branching-
model/
• PDF For Easy Access - https://nvie.com/files/Git-branching-
model.pdf

More Related Content

What's hot

What's hot (20)

Git Branching – the battle of the ages
Git Branching – the battle of the agesGit Branching – the battle of the ages
Git Branching – the battle of the ages
 
Git in 10 minutes
Git in 10 minutesGit in 10 minutes
Git in 10 minutes
 
Github - Git Training Slides: Foundations
Github - Git Training Slides: FoundationsGithub - Git Training Slides: Foundations
Github - Git Training Slides: Foundations
 
Git
GitGit
Git
 
Advanced Git
Advanced GitAdvanced Git
Advanced Git
 
Gitlab ci, cncf.sk
Gitlab ci, cncf.skGitlab ci, cncf.sk
Gitlab ci, cncf.sk
 
Git Lab Introduction
Git Lab IntroductionGit Lab Introduction
Git Lab Introduction
 
Starting with Git & GitHub
Starting with Git & GitHubStarting with Git & GitHub
Starting with Git & GitHub
 
Git branching strategies
Git branching strategiesGit branching strategies
Git branching strategies
 
Git and GitHub | Concept about Git and GitHub Process | Git Process overview
Git and GitHub | Concept about Git and GitHub Process | Git Process overviewGit and GitHub | Concept about Git and GitHub Process | Git Process overview
Git and GitHub | Concept about Git and GitHub Process | Git Process overview
 
Difference between Github vs Gitlab vs Bitbucket
Difference between Github vs Gitlab vs BitbucketDifference between Github vs Gitlab vs Bitbucket
Difference between Github vs Gitlab vs Bitbucket
 
Git flow
Git flowGit flow
Git flow
 
CI CD Basics
CI CD BasicsCI CD Basics
CI CD Basics
 
Git training v10
Git training v10Git training v10
Git training v10
 
CI with Gitlab & Docker
CI with Gitlab & DockerCI with Gitlab & Docker
CI with Gitlab & Docker
 
Git & GitLab
Git & GitLabGit & GitLab
Git & GitLab
 
git and github
git and githubgit and github
git and github
 
Introducing GitLab (September 2018)
Introducing GitLab (September 2018)Introducing GitLab (September 2018)
Introducing GitLab (September 2018)
 
Introducing GitLab (June 2018)
Introducing GitLab (June 2018)Introducing GitLab (June 2018)
Introducing GitLab (June 2018)
 
What is Git | What is GitHub | Git Tutorial | GitHub Tutorial | Devops Tutori...
What is Git | What is GitHub | Git Tutorial | GitHub Tutorial | Devops Tutori...What is Git | What is GitHub | Git Tutorial | GitHub Tutorial | Devops Tutori...
What is Git | What is GitHub | Git Tutorial | GitHub Tutorial | Devops Tutori...
 

Similar to Gitflow - Branching and Merging Flow for Git

A successful Git branching model
A successful Git branching model A successful Git branching model
A successful Git branching model
abodeltae
 
Checkitmobile - using Git for development
Checkitmobile - using Git for developmentCheckitmobile - using Git for development
Checkitmobile - using Git for development
Gerrit Wanderer
 
Checkitmobile advanced git
Checkitmobile advanced gitCheckitmobile advanced git
Checkitmobile advanced git
Gerrit Wanderer
 
Git cheat sheet__grey
Git cheat sheet__greyGit cheat sheet__grey
Git cheat sheet__grey
King Hom
 
Git cheat sheet__white
Git cheat sheet__whiteGit cheat sheet__white
Git cheat sheet__white
King Hom
 
Git cheat sheet_dark
Git cheat sheet_darkGit cheat sheet_dark
Git cheat sheet_dark
King Hom
 

Similar to Gitflow - Branching and Merging Flow for Git (20)

A Git Workflow Model or Branching Strategy
A Git Workflow Model or Branching StrategyA Git Workflow Model or Branching Strategy
A Git Workflow Model or Branching Strategy
 
Git development workflow
Git development workflowGit development workflow
Git development workflow
 
Gitflow
GitflowGitflow
Gitflow
 
Git and GitHub workflows
Git and GitHub workflowsGit and GitHub workflows
Git and GitHub workflows
 
A successful Git branching model
A successful Git branching model A successful Git branching model
A successful Git branching model
 
Checkitmobile - using Git for development
Checkitmobile - using Git for developmentCheckitmobile - using Git for development
Checkitmobile - using Git for development
 
Git basics
Git basicsGit basics
Git basics
 
Checkitmobile advanced git
Checkitmobile advanced gitCheckitmobile advanced git
Checkitmobile advanced git
 
Clarive 7 Branching Model
Clarive 7 Branching ModelClarive 7 Branching Model
Clarive 7 Branching Model
 
How to use Git Branch
How to use Git BranchHow to use Git Branch
How to use Git Branch
 
Introducing Git and git flow
Introducing Git and git flow Introducing Git and git flow
Introducing Git and git flow
 
Nicola Iarocci - Git stories from the front line - Codemotion Milan 2017
Nicola Iarocci - Git stories from the front line - Codemotion Milan 2017Nicola Iarocci - Git stories from the front line - Codemotion Milan 2017
Nicola Iarocci - Git stories from the front line - Codemotion Milan 2017
 
Git tips
Git tipsGit tips
Git tips
 
Introduction into Git
Introduction into GitIntroduction into Git
Introduction into Git
 
Working with Git
Working with GitWorking with Git
Working with Git
 
git Technologies
git Technologiesgit Technologies
git Technologies
 
Switching to Git
Switching to GitSwitching to Git
Switching to Git
 
Git cheat sheet__grey
Git cheat sheet__greyGit cheat sheet__grey
Git cheat sheet__grey
 
Git cheat sheet__white
Git cheat sheet__whiteGit cheat sheet__white
Git cheat sheet__white
 
Git cheat sheet_dark
Git cheat sheet_darkGit cheat sheet_dark
Git cheat sheet_dark
 

Recently uploaded

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Recently uploaded (20)

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 

Gitflow - Branching and Merging Flow for Git

  • 2. Types of VCS & Difference Between Them Centralized DeCentralized As a consequence of its simplicity and repetitive nature, branching and merging are no longer something to be afraid of. Version control tools are supposed to assist in branching/merging more than anything else.
  • 3. Main Concept • Each developer pulls and pushes to origin • But besides the centralized push- pull relationships, each developer may also pull changes from other peers to form sub teams.
  • 4. Develop and Master Branches • Master • We consider origin/master to be the main branch where the source code of HEAD always reflects a production-ready state. • Develop • We consider origin/develop to be the main branch where the source code of HEAD always reflects a state with the latest delivered development changes for the next release. git branch develop git push -u origin develop
  • 5. Supporting branches • Feature branches • Release branches • Hotfix branches Our development model uses a variety of supporting branches to aid parallel development between team members, ease tracking of features, prepare for production releases and to assist in quickly fixing live production problems. Unlike the main branches, these branches always have a limited life time, since they will be removed eventually.
  • 6. Feature(Topic) branches • May branch off from: • develop • Must merge back into: • develop • Branch naming convention: • anything except master, develop, release-*, or hotfix-* Feature branches (or sometimes called topic branches) are used to develop new features for the upcoming or a distant future release. When starting development of a feature, the target release in which this feature will be incorporated may well be unknown at that point. The essence of a feature branch is that it exists as long as the feature is in development, but will eventually be merged back into develop (to definitely add the new feature to the upcoming release) or discarded (in case of a disappointing experiment).
  • 7. Creating a feature branch • When starting work on a new feature, branch off from the develop branch. git checkout -b myfeature develop
  • 8. Incorporating a finished feature on develop • Finished features may be merged into the develop branch to definitely add them to the upcoming release: $ git checkout develop Switched to branch 'develop’ $ git merge --no-ff myfeature Updating ea1b82a..05e9557 (Summary of changes) $ git branch -d myfeature Deleted branch myfeature (was 05e9557). $ git push origin develop
  • 9. --no-ff • The --no-ff flag causes the merge to always create a new commit object, even if the merge could be performed with a fast- forward. This avoids losing information about the historical existence of a feature branch and groups together all commits that together added the feature. Compare: • In the latter case, it is impossible to see from the Git history which of the commit objects together have implemented a feature—you would have to manually read all the log messages. Reverting a whole feature (i.e. a group of commits), is a true headache in the latter situation, whereas it is easily done if the --no-ff flag was used.
  • 10. Release branches • May branch off from: • develop • Must merge back into: • develop and master • Branch naming convention: • release-* • meta-data for a release
  • 11. Creating a release branch $ git checkout -b release-1.2 develop Switched to a new branch "release-1.2" $ ./bump-version.sh 1.2 Files modified successfully, version bumped to 1.2. $ git commit -a -m "Bumped version number to 1.2" [release-1.2 74d9424] Bumped version number to 1.2 1 files changed, 1 insertions(+), 1 deletions(-)
  • 12. Finishing a release branch- Step1 $ git checkout master Switched to branch 'master’ $ git merge --no-ff release-1.2 Merge made by recursive. (Summary of changes) $ git tag -a 1.2
  • 13. Finishing a release branch- Step2 • To keep the changes made in the release branch, we need to merge those back into develop, though. In Git: $ git checkout develop Switched to branch 'develop’ $ git merge --no-ff release-1.2 Merge made by recursive. (Summary of changes)
  • 14. Finishing a release branch- Step3 • This step may well lead to a merge conflict (probably even, since we have changed the version number). If so, fix it and commit. • Now we are really done and the release branch may be removed, since we don’t need it anymore: • $ git branch -d release-1.2 Deleted branch release-1.2 (was ff452fe).
  • 15. Hotfix branches • May branch off from: • master • Must merge back into: • develop and master • Branch naming convention: • hotfix-*
  • 16. Creating a hotfix branch Step-1 • Hotfix branches are created from the master branch. For example, say version 1.2 is the current production release running live and causing troubles due to a severe bug. But changes on develop are yet unstable. We may then branch off a hotfix branch and start fixing the problem: $ git checkout -b hotfix-1.2.1 master Switched to a new branch "hotfix-1.2.1“ $ ./bump-version.sh 1.2.1 Files modified successfully, version bumped to 1.2.1. $ git commit -a -m "Bumped version number to 1.2.1" [hotfix-1.2.1 41e61bb] Bumped version number to 1.2.1 1 files changed, 1 insertions(+), 1 deletions(-)
  • 17. Creating a hotfix branch Step-2 • Then, fix the bug and commit the fix in one or more separate commits. $ git commit -m "Fixed severe production problem" [hotfix-1.2.1 abbe5d6] Fixed severe production problem 5 files changed, 32 insertions(+), 17 deletions(-)
  • 18. Finishing a hotfix branch- Step1 • First, update master and tag the release. $ git checkout master Switched to branch 'master’ $ git merge --no-ff hotfix-1.2.1 Merge made by recursive. (Summary of changes) $ git tag -a 1.2.1
  • 19. Finishing a hotfix branch- Step2 • Next, include the bugfix in develop, too: $ git checkout develop Switched to branch 'develop’ $ git merge --no-ff hotfix-1.2.1 Merge made by recursive. (Summary of changes)
  • 20. Finishing a hotfix branch- Step3 • Finally, remove the temporary branch: • $ git branch -d hotfix-1.2.1 Deleted branch hotfix-1.2.1 (was abbe5d6). $ git branch -d hotfix-1.2.1 Deleted branch hotfix-1.2.1 (was abbe5d6).
  • 21. Summary • While there is nothing really shocking new to this branching model, the “big picture” figure that this post began with has turned out to be tremendously useful in our projects. It forms an elegant mental model that is easy to comprehend and allows team members to develop a shared understanding of the branching and releasing processes. • Reference - https://nvie.com/posts/a-successful-git-branching- model/ • PDF For Easy Access - https://nvie.com/files/Git-branching- model.pdf