SlideShare uma empresa Scribd logo
1 de 24
Baixar para ler offline
Git flow & Git
Init a project with existing files
git flow init
Creates two branches:
master (production release)
develop (next release)
Supported branches prefixes:
feature
release
hotfix
After finishing "my-hotfix", master and develop have the
commits made in the hotfix branch
Hotfixes workflow
Command master my-hotfix develop
git flow hotfix start my-hotfix
working in hotfix
git commit -am "msg"
git flow hotfix finish my-hotfix
git flow hotfix start my-hotfix
is equivalent to the next git commands
git checkout master
git branch hotfix/my-hotfix
git checkout hotfix/my-hotfix
or
git checkout -b hotfix/my-hotfix master
Starting a hotfix
git flow hotfix finish my-hotfix
is equivalent to the next git commands
git checkout master
git merge --no-ff hotfix/my-hotfix
git checkout develop
git merge --no-ff hotfix/my-hotfix
git branch -d hotfix/my-hotfix
don't forget to push master and develop into origin
git push origin [master|develop]
Finishing a hotfix
After finishing "my-feature", only develop has the commits
made in the feature branch
Features workflow
Command master my-feature develop
git flow feature start my-feature
working in feature
git commit -am "msg"
git flow feature finish my-feature
git flow feature start my-feature
is equivalent to the next git commands
git checkout develop
git branch feature/my-feature
git checkout feature/my-feature
or
git checkout -b feature/my-feature develop
Starting a feature
git flow feature finish my-feature
is equivalent to the next git commands
git checkout develop
git merge --no-ff feature/my-feature
git branch -d feature/my-feature
don't forget to push develop into origin
git push origin develop
Finishing a feature
After finishing "v2.0", master and develop have the commits
made in the release branch
Releases workflow
Command master v2.0 develop
git flow release start v2.0
working in release
git commit -am "msg"
git flow feature finish v2.0
git flow release start my-release
is equivalent to the next git commands
git checkout develop
git branch release/my-release
git checkout release/my-release
or
git checkout -b release/my-release develop
Starting a release
git flow release finish my-release
is equivalent to the next git commands
git checkout master
git merge --no-ff release/my-release
git tag -a my-release
git checkout develop
git merge --no-ff release/my-release
git branch -d release/my-release
don't forget to push master and develop into origin
git push origin [master|develop]
Finishing a release
Hotfixes
git checkout master
git pull
git checkout hotfix-branch
git merge master
Features
git checkout develop
git pull
git checkout feature-branch
git merge develop
What if my branch gets obsolete?
git flow [hotfix|feature|release] publish my-branch
you can checkout remote branches like this
git checkout -b my-branch origin/my-branch
don't forget to remove them when they are not needed
anymore
git push origin :my-branch
Publishing remote branches
Suitable to support old versions of the software but in a
very EXPERIMENTAL status and NOT RECOMENDABLE
for production environments
git flow support start v1.1.1 v1.0
Support branches
Useful git
commands
Log of the last 2 commits
git log -2
Differences in the last 2 commits
git log -2 -p
Differences between commits
git diff 77cf297..eb0df61
gif diff --name-only 77cf297..eb0df61f
git diff HEAD..HEAD^1 filename
Showing the last commits
Useful when we need to checkout another branch and we
don't still want to commit anything
git stash
git stash list
git stash pop
git stash apply stash@{0}
git stash show stash@{1}
git stash drop stash@{0}
Saving work without committing
If the file hasn't been added to the index
git checkout one.txt
If the file has already been added to the index
git reset HEAD one.txt
If we want to undo a commit but keeping the modifications
git reset --soft sha1_commit
If we want to undo a commit completely
git reset --hard sha1_commit
Throwing changes away
Fixing mistakes
with git
Committing too early
git commit -m "my message"
I forgot to add the file one.txt and I don't want to do another
commit
git add one.txt
git commit --amend
Committing too early again
git add two.txt three.txt
git commit -m "my message"
I don't want the file three.txt in this commit
git reset HEAD^1 three.txt
git commit --amend
Fixing mistakes in previous commits
An error in the file four.txt was introduced in a previous commit
git checkout <SHA1_commit>
vim four.txt
git add four.txt
git commit --amend
git rebase --onto HEAD <SHA1_commit> <branch>
Recovering local deleted branch
git branch -D my-feature
Looking for the last commit in the deleted branch and
getting its SHA1 with git reflog
git branch my-feature <sha1_last_commit>
Links
● http://git-scm.com/documentation
● http://nvie.com/posts/a-successful-git-branching-model/

Mais conteúdo relacionado

Mais procurados

Mais procurados (20)

Git and Github Session
Git and Github SessionGit and Github Session
Git and Github Session
 
Git 101 for Beginners
Git 101 for Beginners Git 101 for Beginners
Git 101 for Beginners
 
Introduction To Git
Introduction To GitIntroduction To Git
Introduction To Git
 
Git & GitHub WorkShop
Git & GitHub WorkShopGit & GitHub WorkShop
Git & GitHub WorkShop
 
Git flow
Git flowGit flow
Git flow
 
Introduction to Git and GitHub
Introduction to Git and GitHubIntroduction to Git and GitHub
Introduction to Git and GitHub
 
Git Introduction Tutorial
Git Introduction TutorialGit Introduction Tutorial
Git Introduction Tutorial
 
Learning git
Learning gitLearning git
Learning git
 
Git-flow workflow and pull-requests
Git-flow workflow and pull-requestsGit-flow workflow and pull-requests
Git-flow workflow and pull-requests
 
git and github
git and githubgit and github
git and github
 
Git basics to advance with diagrams
Git basics to advance with diagramsGit basics to advance with diagrams
Git basics to advance with diagrams
 
Github - Git Training Slides: Foundations
Github - Git Training Slides: FoundationsGithub - Git Training Slides: Foundations
Github - Git Training Slides: Foundations
 
Git Branching Model
Git Branching ModelGit Branching Model
Git Branching Model
 
Advanced Git
Advanced GitAdvanced Git
Advanced Git
 
Git
GitGit
Git
 
Basic Git Intro
Basic Git IntroBasic Git Intro
Basic Git Intro
 
Git One Day Training Notes
Git One Day Training NotesGit One Day Training Notes
Git One Day Training Notes
 
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
 
Starting with Git & GitHub
Starting with Git & GitHubStarting with Git & GitHub
Starting with Git & GitHub
 
Git Rebase vs Merge
Git Rebase vs MergeGit Rebase vs Merge
Git Rebase vs Merge
 

Destaque

Working with the AOSP - Linaro Connect Asia 2013
Working with the AOSP - Linaro Connect Asia 2013Working with the AOSP - Linaro Connect Asia 2013
Working with the AOSP - Linaro Connect Asia 2013
Opersys inc.
 

Destaque (20)

Web 2.0 - From a Social to a Service Web
Web 2.0 - From a Social to a Service WebWeb 2.0 - From a Social to a Service Web
Web 2.0 - From a Social to a Service Web
 
Micro Web Service - Slim and JWT
Micro Web Service - Slim and JWTMicro Web Service - Slim and JWT
Micro Web Service - Slim and JWT
 
Creating REST Applications with the Slim Micro-Framework by Vikram Vaswani
Creating REST Applications with the Slim Micro-Framework by Vikram VaswaniCreating REST Applications with the Slim Micro-Framework by Vikram Vaswani
Creating REST Applications with the Slim Micro-Framework by Vikram Vaswani
 
Por su seguridad
Por su seguridadPor su seguridad
Por su seguridad
 
Groovy&Grails: desarrollo rápido de aplicaciones
Groovy&Grails: desarrollo rápido de aplicacionesGroovy&Grails: desarrollo rápido de aplicaciones
Groovy&Grails: desarrollo rápido de aplicaciones
 
Privacidad internet
Privacidad internetPrivacidad internet
Privacidad internet
 
Certificaciones Tecnológicas: La acreditación del experto
Certificaciones Tecnológicas: La acreditación del expertoCertificaciones Tecnológicas: La acreditación del experto
Certificaciones Tecnológicas: La acreditación del experto
 
Inteligencia Colectiva
Inteligencia ColectivaInteligencia Colectiva
Inteligencia Colectiva
 
Herramientas gestion proyectos
Herramientas gestion proyectosHerramientas gestion proyectos
Herramientas gestion proyectos
 
Seguridad en dispositivos móviles
Seguridad en dispositivos móvilesSeguridad en dispositivos móviles
Seguridad en dispositivos móviles
 
Certificaciones tecnológicas
Certificaciones tecnológicasCertificaciones tecnológicas
Certificaciones tecnológicas
 
Kanban
KanbanKanban
Kanban
 
Groovy&Grails: desarrollo rápido de aplicaciones
Groovy&Grails: desarrollo rápido de aplicacionesGroovy&Grails: desarrollo rápido de aplicaciones
Groovy&Grails: desarrollo rápido de aplicaciones
 
Manual de uso de la web 2.0
Manual de uso de la web 2.0Manual de uso de la web 2.0
Manual de uso de la web 2.0
 
Continuous Delivery
Continuous DeliveryContinuous Delivery
Continuous Delivery
 
Working with the AOSP - Linaro Connect Asia 2013
Working with the AOSP - Linaro Connect Asia 2013Working with the AOSP - Linaro Connect Asia 2013
Working with the AOSP - Linaro Connect Asia 2013
 
Framework de test spock
Framework de test spock Framework de test spock
Framework de test spock
 
Json web token api authorization
Json web token api authorizationJson web token api authorization
Json web token api authorization
 
Metodologías agiles de desarrollo de software
Metodologías agiles de desarrollo de softwareMetodologías agiles de desarrollo de software
Metodologías agiles de desarrollo de software
 
Testing NodeJS Security
Testing NodeJS SecurityTesting NodeJS Security
Testing NodeJS Security
 

Semelhante a Git and git flow

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
 

Semelhante a Git and git flow (20)

Checkitmobile - using Git for development
Checkitmobile - using Git for developmentCheckitmobile - using Git for development
Checkitmobile - using Git for development
 
Git development workflow
Git development workflowGit development workflow
Git development workflow
 
Mastering git - Workflow
Mastering git - WorkflowMastering git - Workflow
Mastering git - Workflow
 
Git commands
Git commandsGit commands
Git commands
 
Managing releases effectively through git
Managing releases effectively through gitManaging releases effectively through git
Managing releases effectively through git
 
GIT in a nutshell
GIT in a nutshellGIT in a nutshell
GIT in a nutshell
 
Git - Version Control System
Git - Version Control SystemGit - Version Control System
Git - Version Control System
 
Pro git - grasping it conceptually
Pro git - grasping it conceptuallyPro git - grasping it conceptually
Pro git - grasping it conceptually
 
Gitflow - Una metología para manejo de Branches
Gitflow - Una metología para manejo de BranchesGitflow - Una metología para manejo de Branches
Gitflow - Una metología para manejo de Branches
 
GIT Basics
GIT BasicsGIT Basics
GIT Basics
 
How to use git without rage
How to use git without rageHow to use git without rage
How to use git without rage
 
Gitflow - Branching and Merging Flow for Git
Gitflow - Branching and Merging Flow for GitGitflow - Branching and Merging Flow for Git
Gitflow - Branching and Merging Flow for Git
 
Gitflow - Branching and Merging Flow for Git
Gitflow - Branching and Merging Flow for GitGitflow - Branching and Merging Flow for Git
Gitflow - Branching and Merging Flow for Git
 
Checkitmobile advanced git
Checkitmobile advanced gitCheckitmobile advanced git
Checkitmobile advanced git
 
Advanced Git Tutorial
Advanced Git TutorialAdvanced Git Tutorial
Advanced Git Tutorial
 
Git Tricks — git utilities that make life git easier
Git Tricks — git utilities that make life git easierGit Tricks — git utilities that make life git easier
Git Tricks — git utilities that make life git easier
 
Gitt and Git-flow
Gitt and Git-flowGitt and Git-flow
Gitt and Git-flow
 
Git github
Git githubGit github
Git github
 
Gitflow
GitflowGitflow
Gitflow
 
Git workshop
Git workshopGit workshop
Git workshop
 

Último

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 

Último (20)

Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
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
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
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
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 

Git and git flow

  • 2. Init a project with existing files git flow init Creates two branches: master (production release) develop (next release) Supported branches prefixes: feature release hotfix
  • 3. After finishing "my-hotfix", master and develop have the commits made in the hotfix branch Hotfixes workflow Command master my-hotfix develop git flow hotfix start my-hotfix working in hotfix git commit -am "msg" git flow hotfix finish my-hotfix
  • 4. git flow hotfix start my-hotfix is equivalent to the next git commands git checkout master git branch hotfix/my-hotfix git checkout hotfix/my-hotfix or git checkout -b hotfix/my-hotfix master Starting a hotfix
  • 5. git flow hotfix finish my-hotfix is equivalent to the next git commands git checkout master git merge --no-ff hotfix/my-hotfix git checkout develop git merge --no-ff hotfix/my-hotfix git branch -d hotfix/my-hotfix don't forget to push master and develop into origin git push origin [master|develop] Finishing a hotfix
  • 6. After finishing "my-feature", only develop has the commits made in the feature branch Features workflow Command master my-feature develop git flow feature start my-feature working in feature git commit -am "msg" git flow feature finish my-feature
  • 7. git flow feature start my-feature is equivalent to the next git commands git checkout develop git branch feature/my-feature git checkout feature/my-feature or git checkout -b feature/my-feature develop Starting a feature
  • 8. git flow feature finish my-feature is equivalent to the next git commands git checkout develop git merge --no-ff feature/my-feature git branch -d feature/my-feature don't forget to push develop into origin git push origin develop Finishing a feature
  • 9. After finishing "v2.0", master and develop have the commits made in the release branch Releases workflow Command master v2.0 develop git flow release start v2.0 working in release git commit -am "msg" git flow feature finish v2.0
  • 10. git flow release start my-release is equivalent to the next git commands git checkout develop git branch release/my-release git checkout release/my-release or git checkout -b release/my-release develop Starting a release
  • 11. git flow release finish my-release is equivalent to the next git commands git checkout master git merge --no-ff release/my-release git tag -a my-release git checkout develop git merge --no-ff release/my-release git branch -d release/my-release don't forget to push master and develop into origin git push origin [master|develop] Finishing a release
  • 12. Hotfixes git checkout master git pull git checkout hotfix-branch git merge master Features git checkout develop git pull git checkout feature-branch git merge develop What if my branch gets obsolete?
  • 13. git flow [hotfix|feature|release] publish my-branch you can checkout remote branches like this git checkout -b my-branch origin/my-branch don't forget to remove them when they are not needed anymore git push origin :my-branch Publishing remote branches
  • 14. Suitable to support old versions of the software but in a very EXPERIMENTAL status and NOT RECOMENDABLE for production environments git flow support start v1.1.1 v1.0 Support branches
  • 16. Log of the last 2 commits git log -2 Differences in the last 2 commits git log -2 -p Differences between commits git diff 77cf297..eb0df61 gif diff --name-only 77cf297..eb0df61f git diff HEAD..HEAD^1 filename Showing the last commits
  • 17. Useful when we need to checkout another branch and we don't still want to commit anything git stash git stash list git stash pop git stash apply stash@{0} git stash show stash@{1} git stash drop stash@{0} Saving work without committing
  • 18. If the file hasn't been added to the index git checkout one.txt If the file has already been added to the index git reset HEAD one.txt If we want to undo a commit but keeping the modifications git reset --soft sha1_commit If we want to undo a commit completely git reset --hard sha1_commit Throwing changes away
  • 20. Committing too early git commit -m "my message" I forgot to add the file one.txt and I don't want to do another commit git add one.txt git commit --amend
  • 21. Committing too early again git add two.txt three.txt git commit -m "my message" I don't want the file three.txt in this commit git reset HEAD^1 three.txt git commit --amend
  • 22. Fixing mistakes in previous commits An error in the file four.txt was introduced in a previous commit git checkout <SHA1_commit> vim four.txt git add four.txt git commit --amend git rebase --onto HEAD <SHA1_commit> <branch>
  • 23. Recovering local deleted branch git branch -D my-feature Looking for the last commit in the deleted branch and getting its SHA1 with git reflog git branch my-feature <sha1_last_commit>