Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Gitflow - Una metología para manejo de Branches

1,289 views

Published on

Introducción a la metodolgía Gitflow para manejo efectivo de codigó fuente utilizando Git.

  • Be the first to comment

Gitflow - Una metología para manejo de Branches

  1. 1. GitFlow Javier Alvarez @JManGT
  2. 2. Esta obra está licenciada bajo la Licencia Creative Commons Atribución-CompartirIgual 4.0 Internacional. Para ver una copia de esta licencia, visita http://creativecommons.org/licenses/by-sa/4.0/.
  3. 3. GIT Versionamiento de Código
  4. 4. Lo Básico Environments, Branches, Tags, Merge
  5. 5. Environments Vagrant + Puppet
  6. 6. Branches $ git branch > * master
  7. 7. Branches $ git branch mi-branch > * master mi-branch
  8. 8. Branches Master abc001 abc002 …. abc008 commits branch
  9. 9. Branches Master abc001 abc002 …. abc008 Mi-branch xyz001 xyz002 … $ git checkout mi-branch
  10. 10. Tags Master abc001 abc002 …. abc123 Mi-branch xyz001 xyz002 … V0.2.0V0.1.0 xyz025 $ git tag –a v0.2.0
  11. 11. Tags Master abc001 abc002 …. abc123 Mi-branch xyz001 xyz002 … V0.2.0V0.1.0 xyz025
  12. 12. Tags Master abc001 abc002 …. abc123 Mi-branch xyz001 xyz002 … V0.2.0V0.1.0 xyz025 opq001 Experimento $ git branch experimento
  13. 13. Merge Master abc001 abc002 …. abc123 Mi-branch xyz001 xyz002 V0.1.0 xyz025 xyz025 V0.2.0 $ git merge experimiento
  14. 14. Merge Master abc001 abc002 …. abc123 Mi-branch xyz001 xyz002 V0.1.0 xyz025 xyz025 V0.2.0 $ git branch -D mi-branch
  15. 15. Checkout Master abc001 abc002 …. abc123 V0.1.0 xyz025 V0.2.0 $ git clone repo $ git tags –l > v0.2.0 v0.1.0 $ git checkout tags/v0.2.0 $ git checkout tags/v0.1.0
  16. 16. Workflow Problemas Comunes
  17. 17. Master a Master MasterMaster Mi Máquina El Server $ git push server master
  18. 18. Master a Master MasterMaster El Server No es posible corregir el bug hasta completar el feature V0.1.0 abc001 abc002 Nuevo Feature abc001 abc003 abc123 ¡BUG! Feature Incompleto
  19. 19. Master / Edge MasterMaster Mi Máquina El Server Dos branches en la máquina de desarrollo Edge V0.1.0 abc001 abc123
  20. 20. Master / Edge MasterMaster Mi Máquina El Server Podemos corregir el bug directamente a master Edge V0.1.0 abc001 abc123
  21. 21. Master / Edge MasterMaster Mi Máquina El Server Agregamos el bugfix a Edge Edge V0.1.0 abc001 abc123 xyz001 xyz001 xyz001
  22. 22. Workflow Trabajo en Equipo
  23. 23. En Equipo Master Cada desarrollador trabaja a partir de Edge Edge abc123 abc001V0.1.0 Edge xyz033 Edge opq654 Pedro Juan
  24. 24. Release Master Todos hacen push a edge Edge abc001V0.1.0 Edge Edge Pedro Juan V0.2.0
  25. 25. Release Lo que se prueba no es lo que se libera MasterEdge Bug - MarioFeature - JuanMario - Edge
  26. 26. Gitflow Metodología de Branching
  27. 27. Branches Principales Master 2 branch permanentes Edge Commit Inicial Version 1.0 Version 2.0 Nuevos Features
  28. 28. Branches Desarrollo Principales • Master • Edge Desarrollo • Feature • Release • Hotfix
  29. 29. Feature Branch Independizar el desarrollo de features
  30. 30. Feature Branch Master Branch temporal hasta completar el feature Edge Commit Inicial Version 1.0 Version 2.0 Feature Feature Completo
  31. 31. Feature Branch Generamos un nuevo feature branch desde edge EdgeFeature Feature Completo $ git checkout feature edge
  32. 32. Feature Branch Completamos el feature haciendo merge a edge y borrando el feature branch EdgeFeature Feature Completo $ git checkout edge $ git merge –no-ff feature $ git branch –d feature $ git push origin develop
  33. 33. Feature Branch Multiples feature branches se actualizan desde Edge Edgefeature/Bfeature/A
  34. 34. Release Branch Congelar y Estabilizar
  35. 35. Release Branch Congelamos el código del release Edge Release/0.2.0 Feature/A Master Bump a 0.2.0 V0.1.0 $ git checkout –b release/0.2.0 edge < bump de la version de mi codigo > $ git commit –am “Bump 0.2.0”
  36. 36. Release Branch Estabilizamos el código del release Edge Release Feature/A Master V0.1.0 Código estable
  37. 37. Release Branch Edge puede segir avanzando independientemente Edge Release Feature/A Master v0.2.0 V0.1.0 Feature/B Feature/C Código estable
  38. 38. Finalizar Release Dos pasos para finalizar el Release Branch Edge Release/0.2.0Master V0.1.0 v0.2.0
  39. 39. Finalizar Release Merge de feature a master. Generar release tag. Edge Release/0.2.0Master V0.1.0 $ git checkout master $ git merge –no-ff release/0.2.0 $ git tag –a v0.2.0 V0.2.0
  40. 40. Finalizar Release Merge de feature a master. Generar release tag. Edge Release/0.2.0Master V0.1.0 $ git checkout develop $ git merge –no-ff release/0.2.0 $ git tag –a v0.2.0 V0.2.0
  41. 41. Finalizar Release Eliminamos el release branch Edge Release/0.2.0Master V0.1.0 $ git branch –d release/0.2.0 V0.2.0
  42. 42. Finalizar Release Master está estable y Edge tiene nuevos features. Release/0.2.0Master V0.1.0 V0.2.0 Edge Feature/A Feature/A Feature/A Feature/B Feature/C A, B y C
  43. 43. Hotfix Branch Correción de Errores FATALES
  44. 44. Hotfix Branch Hotfix branch nace desde Master Hotfix MasterEdge v0.2.0 v0.2.1
  45. 45. Hotfix Branch Generamos un hotfix branch y hacemos bump de la version Hotfix MasterEdge v0.2.0 $ git branch –d hotfix/0.2.1 master <Bump de version a 0.2.1> $ git commit –am “Bump a 0.2.1”
  46. 46. Hotfix Branch Corregimos el bug Hotfix MasterEdge v0.2.0 $ git commit –am “Fix bug #123”
  47. 47. Finalizar Hotfix Finalizamos Hotfix branch haciendo merge a master. Hotfix MasterEdge v0.2.0 $ git checkout master $ git merge –-no-ff hotfix/0.2.1 $ git tag –a 0.2.1 v0.2.1
  48. 48. Finalizar Hotfix Incluimos el parche tambien en edge. Hotfix MasterEdge v0.2.0 $ git checkout edge $ git merge –-no-ff hotfix/0.2.1 v0.2.1
  49. 49. Finalizar Hotfix Eliminamos el Hotfix Branch Hotfix MasterEdge v0.2.0 $ git branch –d hotfix/0.2.1 v0.2.1
  50. 50. Gitflow Git plugin https://github.com/nvie/gitflow
  51. 51. Gitflow Git plugin Ubuntu # apt-get install git-flow Fedora # yum install gitflow Mac $ brew install git-flow
  52. 52. Inicializar Repositorio ➜ mi-app git:(master) ✗ git flow init No branches exist yet. Base branches must be created now. Branch name for production releases: [master] Branch name for "next release" development: [develop] edge How to name your supporting branch prefixes? Feature branches? [feature/] Release branches? [release/] Hotfix branches? [hotfix/] Support branches? [support/] Version tag prefix? [] ➜ mi-app git:(edge) ✗
  53. 53. Feature Branch ➜ mi-app git:(edge) ✗ git flow feature start homepage Switched to a new branch 'feature/homepage' Summary of actions: - A new branch 'feature/homepage' was created, based on 'edge' - You are now on branch 'feature/homepage' Now, start committing on your feature. When done, use: git flow feature finish homepage ➜ mi-app git:(feature/homepage) ✗
  54. 54. Finalizar Feature Branch ➜ mi-app git:(feature/homepage) git flow feature finish homepage Switched to branch 'edge' Updating 4d2c7d8..0812b3b Fast-forward hello.txt | 0 homepage.html | 0 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 hello.txt create mode 100644 homepage.html Deleted branch feature/homepage (was 0812b3b). Summary of actions: - The feature branch 'feature/homepage' was merged into 'edge' - Feature branch 'feature/homepage' has been removed - You are now on branch 'edge' ➜ mi-app git:(edge)
  55. 55. Release Branch ➜ mi-app git:(edge) git flow release start v0.1.0 Switched to a new branch 'release/v0.1.0' Summary of actions: - A new branch 'release/v0.1.0' was created, based on 'edge' - You are now on branch 'release/v0.1.0' Follow-up actions: - Bump the version number now! - Start committing last-minute fixes in preparing your release - When done, run: git flow release finish 'v0.1.0’ ➜ mi-app git:(release/v0.1.2)
  56. 56. Release Branch ➜ mi-app git:(release/v0.1.0) git flow release finish v0.1.0 Switched to branch 'master' Merge made by the 'recursive' strategy. hello.txt | 0 homepage.html | 0 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 hello.txt create mode 100644 homepage.html Deleted branch release/v0.1.0 (was 0812b3b). Summary of actions: - Latest objects have been fetched from 'origin' - Release branch has been merged into 'master' - The release was tagged 'v0.1.0' - Release branch has been back-merged into 'edge' - Release branch 'release/v0.1.0' has been deleted ➜ mi-app git:(master)
  57. 57. Hotfix Branch ➜ mi-app git:(master) git flow hotfix start v0.1.1 Switched to a new branch 'hotfix/v0.1.1' Summary of actions: - A new branch 'hotfix/v0.1.1' was created, based on 'master' - You are now on branch 'hotfix/v0.1.1' Follow-up actions: - Bump the version number now! - Start committing your hot fixes - When done, run: git flow hotfix finish 'v0.1.1' ➜ mi-app git:(hotfix/v0.1.1)
  58. 58. Hotfix Branch ➜ mi-app git:(hotfix/v0.1.1) ✗ git commit -am "Fix bug #123" [hotfix/v0.1.1 f7f9caa] Fix bug #123 1 file changed, 1 insertion(+) ➜ mi-app git:(hotfix/v0.1.1) git flow hotfix finish v0.1.1 Switched to branch 'master' Merge made by the 'recursive' strategy. homepage.html | 1 + 1 file changed, 1 insertion(+) Switched to branch 'edge' Merge made by the 'recursive' strategy. homepage.html | 1 + 1 file changed, 1 insertion(+) Deleted branch hotfix/v0.1.1 (was f7f9caa). Summary of actions: - Latest objects have been fetched from 'origin' - Hotfix branch has been merged into 'master' - The hotfix was tagged 'v0.1.1' - Hotfix branch has been back-merged into 'edge' - Hotfix branch 'hotfix/v0.1.1' has been deleted ➜ mi-app git:(edge)
  59. 59. A successful Git branching model http://nvie.com/posts/a-successful-git-branching-model/
  60. 60. Gracias por su sintonía @JmanGt Javier Alvarez

×