<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Fernando Ayon</title>
    <description>The latest articles on DEV Community by Fernando Ayon (@fernando_ayon).</description>
    <link>https://dev.to/fernando_ayon</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F317304%2F430754bd-b3dd-47dc-ba41-8c7aed9e92d8.png</url>
      <title>DEV Community: Fernando Ayon</title>
      <link>https://dev.to/fernando_ayon</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/fernando_ayon"/>
    <language>en</language>
    <item>
      <title>☕ Git-Flow : premiers pas</title>
      <dc:creator>Fernando Ayon</dc:creator>
      <pubDate>Mon, 08 Jun 2020 20:16:36 +0000</pubDate>
      <link>https://dev.to/fernando_ayon/git-flow-premiers-pas-e93</link>
      <guid>https://dev.to/fernando_ayon/git-flow-premiers-pas-e93</guid>
      <description>&lt;p&gt;🇬🇧 &lt;a href="https://dev.to/fernando_ayon/git-flow-an-introduction-430m"&gt;English version&lt;/a&gt;&lt;br&gt;
🇪🇸 &lt;a href="https://dev.to/fernando_ayon/git-flow-lo-esencial-3bgf"&gt;Version en español&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Tu as un nouveau job ou tu prévois de mettre en place Git-Flow dans tes projets, mais tu ne sais pas trop ce que c'est ? Tu es au bon endroit. &lt;/p&gt;

&lt;p&gt;Dans cet article, je vais te l'expliquer, mais si tu connais déjà un peu le principe ou alors si tu veux uniquement des indications sur son utilisation, passe directement au tutoriel.&lt;/p&gt;
&lt;h1&gt;
  
  
  🧐 Le Contexte
&lt;/h1&gt;

&lt;p&gt;En quelques mots, &lt;a href="https://git-scm.com/" rel="noopener noreferrer"&gt;Git&lt;/a&gt; est un système de gestion de versions pour software, c'est un outil indispensable pour contrôler le cycle de vie du développement d'une application.&lt;/p&gt;

&lt;p&gt;Jusqu'ici tout va bien, mais les problèmes commencent à apparaître lorsque l'on travaille en équipe : vous pouvez décider de travailler uniquement sur la branche principale du projet et de créer des branches secondaires lors d'occasions spéciales. Mais que se passe-t-il lorsqu'il y a beaucoup de travail ou lorsque plusieurs personnes doivent travailler sur la même chose en même temps ?&lt;/p&gt;
&lt;h2&gt;
  
  
  📓 &lt;a href="https://nvie.com/posts/a-successful-git-branching-model/" rel="noopener noreferrer"&gt;Git-Flow&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;Dès que nous travaillons en équipe, il est nécessaire de définir des conventions ou des bonnes pratiques pour que nous puissions travailler ensemble. Git-Flow est l'un des nombreux outils que nous qualifions de &lt;em&gt;workflows&lt;/em&gt;. C'est un moyen d'organiser les branches du projet, assez populaire de part sa praticité et son apprentissage relativement rapide.&lt;/p&gt;

&lt;p&gt;Tu as probablement déjà vu cette image ou une image similaire lors d'une recherche du terme Git-Flow sur Internet:&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F8uwtwsr8ktejnuh4rad6.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F8uwtwsr8ktejnuh4rad6.jpg" alt="*Visible confusion*"&gt;&lt;/a&gt; &lt;em&gt;Git-Flow&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Cela semble et est compliqué à première vue, mais dès que nous connaissons les différentes branches utilisées et la raison de leur existence, tu verras que leur fonctionnement est assez logique.&lt;/p&gt;
&lt;h3&gt;
  
  
  🌳 Branches
&lt;/h3&gt;

&lt;p&gt;Comme nous l'avons vu dans l'image, Git-Flow utilise plusieurs branches pour organiser le développement:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;master&lt;/li&gt;
&lt;li&gt;develop&lt;/li&gt;
&lt;li&gt;feature&lt;/li&gt;
&lt;li&gt;release&lt;/li&gt;
&lt;li&gt;hotfix&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;
  
  
  🌴 master et develop
&lt;/h4&gt;

&lt;p&gt;Si tu as déjà utilisé Git, tu connais forcément la branche &lt;code&gt;master&lt;/code&gt;. Dans ce nouveau contexte, cette branche est "intouchable", aucun membre de l'équipe ne doit y apporter de modifications directement, ni en créer de nouvelles, à une exception que nous verrons plus tard.&lt;/p&gt;

&lt;p&gt;Lors de la création d'un nouveau projet, ou lorsque tu commences à utiliser Git-Flow, la branche &lt;code&gt;develop&lt;/code&gt; doit être créée à partir de &lt;code&gt;master&lt;/code&gt;, et comme &lt;code&gt;master&lt;/code&gt;, la branche &lt;code&gt;develop&lt;/code&gt; ne sera jamais supprimée et vivra en parallèle.&lt;/p&gt;

&lt;p&gt;Comme son nom l'indique, la branche &lt;code&gt;develop&lt;/code&gt; sert de base au développement de toutes les nouvelles fonctionnalités et corrections du projet, c'est pourquoi elle est considérée comme la branche principale.&lt;/p&gt;

&lt;p&gt;Une fois que toutes les nouvelles fonctions et corrections prévues du projet sont terminées et que &lt;code&gt;develop&lt;/code&gt; est stable, on peut faire un &lt;code&gt;merge&lt;/code&gt; de &lt;code&gt;develop&lt;/code&gt; dans &lt;code&gt;master&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;La branche &lt;code&gt;master&lt;/code&gt; doit toujours refléter un état 'en production', il est donc important de ne pas y apporter de modifications directement, car chaque fois qu'il y a un nouveau &lt;code&gt;commit&lt;/code&gt;, on doit faire un &lt;code&gt;tag&lt;/code&gt; pour définir la nouvelle version et la publier. C'est pourquoi on appellera la branche &lt;code&gt;master&lt;/code&gt; comme la 'branche d'intégration'.&lt;/p&gt;
&lt;h4&gt;
  
  
  💯 feature
&lt;/h4&gt;

&lt;p&gt;Les branches &lt;code&gt;feature&lt;/code&gt; sont celles que nous devons consacrer entièrement au développement de chacune des nouvelles fonctionnalités du projet dans sa prochaine version. Elles partent toujours de &lt;code&gt;develop&lt;/code&gt; et à la fin du développement on doit les &lt;code&gt;merger&lt;/code&gt; de retour sur &lt;code&gt;develop&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Si nous suivons les bonnes pratiques de Git-Flow, lors de la création d'une nouvelle branche &lt;code&gt;feature&lt;/code&gt;, nous devons toujours ajouter le préfixe &lt;code&gt;feature/*&lt;/code&gt;, de cette façon nous pouvons maintenir une bonne organisation et si nous regardons les branches actives nous pouvons rapidement identifier le travail en cours.&lt;/p&gt;

&lt;p&gt;Il est très important de nommer les branches &lt;code&gt;feature&lt;/code&gt; de manière descriptive pour identifier le but de la branche :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;❌ feature/new-method
✔️ feature/add-support-for-json-parsing
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Ce qu'il faut retenir est que les branches &lt;code&gt;feature&lt;/code&gt; ne vivent que pendant le développement et qu'elles disparaissent une fois qu'on fait le &lt;code&gt;merge&lt;/code&gt; du développement ou alors nous pouvons les supprimer si la fonction en développement n'est plus nécessaire, par exemple dans le cas des fonctions expérimentales.&lt;/p&gt;

&lt;p&gt;NOTE: le préfixe &lt;code&gt;feature/*&lt;/code&gt; est la pratique par défaut, mais si ton équipe et toi le jugent nécessaire, vous pouvez adapter le préfixe à une autre chose, par exemple : &lt;code&gt;fonction/*&lt;/code&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  ⭐ release
&lt;/h4&gt;

&lt;p&gt;Les branches &lt;code&gt;release&lt;/code&gt; sont utilisées pour regrouper les fonctionnalités et les corrections apportées pour préparer la sortie de la version en développement. Elles partent de &lt;code&gt;develop&lt;/code&gt; et le &lt;code&gt;merge&lt;/code&gt; doit se faire à la fois dans &lt;code&gt;develop&lt;/code&gt; et dans &lt;code&gt;master&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Le moment idéal pour créer les branches &lt;code&gt;release&lt;/code&gt; est lorsque la branche &lt;code&gt;develop&lt;/code&gt; est aussi similaire que possible à ce que nous voulons avoir en production, c'est un moyen de faire des petites corrections oubliées de dernière minute, ou de faire des méta-changements au projet qui n'ont pas lieu sur une branche feature, par exemple, pour augmenter le numéro de version.&lt;/p&gt;

&lt;p&gt;Si nous suivons les bonnes pratiques de Git-Flow, les branches &lt;code&gt;release&lt;/code&gt; ont également un préfixe, &lt;code&gt;release/*&lt;/code&gt; ou &lt;code&gt;release-*&lt;/code&gt;, généralement suivi du numéro de version ou du nom qu'elles représentent, par exemple, &lt;code&gt;release/1.2.0&lt;/code&gt; ou &lt;code&gt;release/5.0&lt;/code&gt; ou encore &lt;code&gt;release/1.0.0-rc.1+build.123&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;L'avantage des branches &lt;code&gt;release&lt;/code&gt; est que le travail peut se poursuivre sur la branche &lt;code&gt;develop&lt;/code&gt; et d'autres nouvelles &lt;code&gt;features&lt;/code&gt;, car le travail prévu pour la nouvelle version est déjà présent dans la branche &lt;code&gt;release&lt;/code&gt; et n'aura pas de changements majeurs.&lt;/p&gt;

&lt;h4&gt;
  
  
  🛠️ hotfix
&lt;/h4&gt;

&lt;p&gt;Les branches &lt;code&gt;hotfix&lt;/code&gt; partent de &lt;code&gt;master&lt;/code&gt; et nous devons faire le &lt;code&gt;merge&lt;/code&gt; de retour dans &lt;code&gt;master&lt;/code&gt; et &lt;code&gt;develop&lt;/code&gt;. Elles sont utilisées pour apporter des corrections rapides au projet, afin de publier une nouvelle version dès que possible.&lt;/p&gt;

&lt;p&gt;NOTE: Si nous créons une branche &lt;code&gt;hotfix&lt;/code&gt; mais qu'il y a déjà une branche &lt;code&gt;release&lt;/code&gt;, au lieu de faire le &lt;code&gt;merge&lt;/code&gt; dans &lt;code&gt;develop&lt;/code&gt;, nous devons le faire dans &lt;code&gt;master&lt;/code&gt; et dans la &lt;code&gt;release&lt;/code&gt;.&lt;/p&gt;

&lt;h4&gt;
  
  
  ⚔️ hotfix vs bugfix
&lt;/h4&gt;

&lt;p&gt;Dans certains projets, tu pourras trouver qu'en plus des branches &lt;code&gt;hotfix&lt;/code&gt;, il y en a parfois quelques-unes avec le préfixe &lt;code&gt;bugfix&lt;/code&gt;. La différence entre ces deux types de branches est que les &lt;code&gt;bugfix&lt;/code&gt; se comportent comme les branches &lt;code&gt;feature&lt;/code&gt; et les &lt;code&gt;hotfix&lt;/code&gt; se comportent comme les branches &lt;code&gt;release&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Autrement dit, tu peux utiliser les &lt;code&gt;bugfix&lt;/code&gt; pour apporter des corrections de bugs mineurs qui peuvent attendre la sortie de la version en développement, tandis que les &lt;code&gt;hotfix&lt;/code&gt; ne peuvent pas attendre et doivent être publiées dès que le développement soit approuvé.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;✔️ bugfix/fix-some-thingy-that-almost-nobody-uses-and-its-not-really-important
✔️ hotfix/fix-clic-on-top-right-corner-of-login-button-sets-the-users-computer-on-fire
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  ✏️ Tutoriel &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Pour ce tuto et afin de le simplifier au maximum, j'utiliserai le plugin de console Git-Flow de &lt;a href="https://github.com/petervanderdoes/gitflow-avh" rel="noopener noreferrer"&gt;Peter van der Does&lt;/a&gt;, mais je te laisse ici les &lt;a href="https://gist.github.com/JamesMGreene/cdd0ac49f90c987e45ac" rel="noopener noreferrer"&gt;commandes Git classiques équivalentes&lt;/a&gt; aux commandes Git-Flow.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Activer Git-Flow sur le projet&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Cette commande active Git sur le projet, elle crée aussi la branche develop et &lt;/span&gt;
&lt;span class="c"&gt;# permet de configurer les préfixes des autres branches.&lt;/span&gt;
&lt;span class="c"&gt;# Enfin, elle fait un check out de la branche develop&lt;/span&gt;
git flow init
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F5ush55zzd9oaqorna9pf.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F5ush55zzd9oaqorna9pf.gif" alt="git flow init"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Commencer à travailler sur une nouvelle fonctionnalité&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Cette commande crée une nouvelle branche feature/* et fait un check out sur la branche&lt;/span&gt;
git flow feature start &amp;lt;feature-name&amp;gt;
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fdw1ll43xgdzzncqpxxt2.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fdw1ll43xgdzzncqpxxt2.gif" alt="git flow feature start"&gt;&lt;/a&gt;&lt;br&gt;
Tu peux voir comment la console nous indique les actions effectuées et que nous pouvons commencer à travailler sur la nouvelle branche.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Terminer une fonctionnalité&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt; &lt;span class="c"&gt;# Le nom de la feature est optionnel, il n'est pas nécessaire de le préciser si&lt;/span&gt;
 &lt;span class="c"&gt;# on est déjà positionnés sur la branche.&lt;/span&gt;
 &lt;span class="c"&gt;# La commande fait un check out de develop et fait un merge vers develop&lt;/span&gt;
 &lt;span class="c"&gt;# Enfin, elle supprime la branche feature&lt;/span&gt;
 git flow feature finish &amp;lt;feature-name&amp;gt;
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F7twy4bwoq6r4m2dr7edc.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F7twy4bwoq6r4m2dr7edc.gif" alt="git flow feature finish"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;NOTE: Toutes ces actions sont effectuées dans votre dépôt local, rien n'est fait dans le dépôt distant, sauf si tu fais un &lt;code&gt;push&lt;/code&gt;. Alors n'oublie pas de faire un push lors de la finalisation de ton travail local sur tes &lt;code&gt;feature&lt;/code&gt;s, pour mettre à jour &lt;code&gt;develop&lt;/code&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Préparation de la nouvelle version&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Cette commande crée une nouvelle branche release/* à partir de develop et fait un check out de la branche.&lt;/span&gt;
git flow release start &amp;lt;version-name&amp;gt;
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fxa9tsuaqyghc0lzxzya4.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fxa9tsuaqyghc0lzxzya4.gif" alt="git flow release start"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;NOTE: Le moment parfait pour publier la branche &lt;code&gt;release&lt;/code&gt; dans le dépôt distant c'est juste après la mise à jour du numéro de version de ton projet (et la validation du code, évidemment).&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Finaliser la version&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Cette commande fait un check out de la branche master&lt;/span&gt;
&lt;span class="c"&gt;# Ensuite, fait un merge de la branche release&lt;/span&gt;
&lt;span class="c"&gt;# Elle crée le tag de la version sur master avec le nom de la branche release&lt;/span&gt;
&lt;span class="c"&gt;# Elle fait un check out de la branche develop&lt;/span&gt;
&lt;span class="c"&gt;# Ensuite un merge de la release sur develop&lt;/span&gt;
&lt;span class="c"&gt;# Enfin, la branche release est supprimée&lt;/span&gt;
git flow release finish

&lt;span class="c"&gt;# N'oublie pas d'envoyer ces derniers changements vers le dépôt distant avec les commandes classiques de Git :&lt;/span&gt;
git push origin master
git push origin develop
git push &lt;span class="nt"&gt;--tags&lt;/span&gt;
git push origin :release/&amp;lt;version&amp;gt; &lt;span class="o"&gt;(&lt;/span&gt;seulement si la release existait déjà dans le dépôt distant&lt;span class="o"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F9wnd7eyv1kd44hrtgkkl.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F9wnd7eyv1kd44hrtgkkl.gif" alt="git flow release finish"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Création d'un hotfix&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Cette branche peut être créée à partir d'un commit spécifique ou alors du dernier commit.&lt;/span&gt;
&lt;span class="c"&gt;# Cette commande crée une branche hotfix et fait un check out sur la nouvelle branche&lt;/span&gt;
git flow hotfix start &amp;lt;hotfix-name&amp;gt; &lt;span class="o"&gt;[&lt;/span&gt;&amp;lt;commit&amp;gt;]
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fzk7rio07c4kouvbfkxej.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fzk7rio07c4kouvbfkxej.gif" alt="git flow hotfix start"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Finalisation d'un hotfix&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Cette commande effectue les mêmes actions que pour une release&lt;/span&gt;
&lt;span class="c"&gt;# N'oublie pas de spécifier l'option -T ou --tagname&lt;/span&gt;
&lt;span class="c"&gt;# pour créer un tag correctement si le nom de ta&lt;/span&gt;
&lt;span class="c"&gt;# branche hotfix n'est pas un numéro de version.&lt;/span&gt;
git flow hotfix finish &lt;span class="o"&gt;[&lt;/span&gt;&amp;lt;&lt;span class="nt"&gt;-T&lt;/span&gt; version-name&amp;gt;]
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Ffoisegiro6knb6bse4ag.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Ffoisegiro6knb6bse4ag.gif" alt="git flow hotfix finish"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Et pour la suite...
&lt;/h2&gt;

&lt;p&gt;Dans un prochain article, nous parlerons d'autres stratégies, mais si tu veux approfondir le sujet de Git-Flow, voici quelques sources que j'ai utilisées pour cet article.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://nvie.com/posts/a-successful-git-branching-model/" rel="noopener noreferrer"&gt;A successul Git branching model&lt;/a&gt;: L'article d'origine de Git-Flow&lt;br&gt;
&lt;a href="https://danielkummer.github.io/git-flow-cheatsheet/" rel="noopener noreferrer"&gt;Git-Flow cheat sheet&lt;/a&gt;: Un coup d’œil sur les commandes Git-Flow.&lt;br&gt;
&lt;a href="https://www.endoflineblog.com/gitflow-considered-harmful" rel="noopener noreferrer"&gt;GitFlow considered harmful&lt;/a&gt;: Une alternative plus simple à Git-Flow et un avant-goût du sujet de mon prochain article.&lt;/p&gt;

</description>
      <category>git</category>
      <category>beginners</category>
      <category>gitflow</category>
      <category>versioning</category>
    </item>
    <item>
      <title>☕ Git-Flow: an introduction</title>
      <dc:creator>Fernando Ayon</dc:creator>
      <pubDate>Mon, 08 Jun 2020 16:53:52 +0000</pubDate>
      <link>https://dev.to/fernando_ayon/git-flow-an-introduction-430m</link>
      <guid>https://dev.to/fernando_ayon/git-flow-an-introduction-430m</guid>
      <description>&lt;p&gt;🇪🇸 &lt;a href="https://dev.to/fernando_ayon/git-flow-lo-esencial-3bgf"&gt;Version en español&lt;/a&gt;&lt;br&gt;
🇫🇷 &lt;a href="https://dev.to/fernando_ayon/git-flow-premiers-pas-e93"&gt;Version française&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Got a new job or in your current one they are planning to implement Git-Flow and you don't know what the fuss is all about?&lt;/p&gt;

&lt;p&gt;You've come to the right place. In this post I'll break it down for you, however, if you already know it and just want to tinker around with it, you can just skip to the tutorial.&lt;/p&gt;
&lt;h1&gt;
  
  
  🧐 The Context
&lt;/h1&gt;

&lt;p&gt;In a few words, &lt;a href="https://git-scm.com/" rel="noopener noreferrer"&gt;Git&lt;/a&gt; is a version control system, an essential tool to handle the life cycle of the development of an application.&lt;/p&gt;

&lt;p&gt;So far so good, classic Git, but problems start showing up when handling teamwork: you and your team might decide to just work on the main branch of the project and create some secondary branches on special occasions, but what happens when there is a lot of work or several people must work in the same function at the same time?&lt;/p&gt;
&lt;h2&gt;
  
  
  📓 &lt;a href="https://nvie.com/posts/a-successful-git-branching-model/" rel="noopener noreferrer"&gt;Git-Flow&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;When working as a team, it is necessary to define conventions or good practices so that everyone knows how to work together. Git-Flow is one of many so-called &lt;em&gt;workflows&lt;/em&gt;, quite popular for its practicality and relatively quick learning, it is a way to organize the branches of the project repository.&lt;/p&gt;

&lt;p&gt;You have probably already seen this image or a similar one when searching the term Git-Flow on the Internet:&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F8uwtwsr8ktejnuh4rad6.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F8uwtwsr8ktejnuh4rad6.jpg" alt="*Visible confusion*"&gt;&lt;/a&gt; &lt;em&gt;A picture is worth a thousand words, or in this case a couple thousand more&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;It seems and is complicated at first glance, but when you know the different branches used and the reason for their existence, you will see that the handling is quite logical.&lt;/p&gt;
&lt;h3&gt;
  
  
  🌳 Branches
&lt;/h3&gt;

&lt;p&gt;As we saw in the image, Git-Flow uses several branches to organize the development:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;master&lt;/li&gt;
&lt;li&gt;develop&lt;/li&gt;
&lt;li&gt;feature&lt;/li&gt;
&lt;li&gt;release&lt;/li&gt;
&lt;li&gt;hotfix&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;
  
  
  🌴 master &amp;amp; develop
&lt;/h4&gt;

&lt;p&gt;If you have used Git before, you will be familiar with the &lt;code&gt;master&lt;/code&gt; branch. In this new context, this branch is "untouchable", no one from the team should make any changes directly to it, nor create new branches from it, with one exception that we will review later.&lt;/p&gt;

&lt;p&gt;When creating a new project, or when starting to use Git-Flow, the &lt;code&gt;develop&lt;/code&gt; branch must be created from&lt;code&gt;master&lt;/code&gt;, and like &lt;code&gt;master&lt;/code&gt;, it will be a "long-lived branch", that is, it will never be deleted and will be parallel to &lt;code&gt;master&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;As its name implies, the &lt;code&gt;develop&lt;/code&gt; branch serves as the basis for working on all new project features and fixes, which is why it is considered the main branch.&lt;/p&gt;

&lt;p&gt;Once all the new project functions &amp;amp; bugfixes have been completed and &lt;code&gt;develop&lt;/code&gt; is on a rather 'stable' state, we should &lt;code&gt;merge&lt;/code&gt; develop in &lt;code&gt;master&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;master&lt;/code&gt; branch should always reflect an 'production' state, so it is important that we do not make changes directly to it, since every time there is a new &lt;code&gt;commit&lt;/code&gt;, we should &lt;code&gt;tag&lt;/code&gt; it to define the new version and publish it. In this context the &lt;code&gt;master&lt;/code&gt; branch is sometimes referred to as the 'integration' branch.&lt;/p&gt;
&lt;h4&gt;
  
  
  💯 feature
&lt;/h4&gt;

&lt;p&gt;The &lt;code&gt;feature&lt;/code&gt; branches are those that we dedicate completely to the development of each of the new &lt;em&gt;planned&lt;/em&gt; functions to be added to the project in the next version. They come always from &lt;code&gt;develop&lt;/code&gt; and we must &lt;code&gt;merge&lt;/code&gt; 'em back to &lt;code&gt;develop&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Following Git-Flow best practices, when creating a new &lt;code&gt;feature&lt;/code&gt; branch, we must always add the prefix &lt;code&gt;feature/&lt;/code&gt;, in this way we can maintain a good organization and just by looking at the active branches we can quickly identify the work in progress.&lt;/p&gt;

&lt;p&gt;At the same time, it is important to name the &lt;code&gt;feature&lt;/code&gt; branches in a descriptive way to identify the purpose of the branch:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;❌ feature/new-method
✔️ feature/add-support-for-json-parsing
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The important thing about feature branches is that they only live during development and that they should disappear once we have done the &lt;code&gt;merge&lt;/code&gt; in &lt;code&gt;develop&lt;/code&gt; or that they are discarded if the function is no longer necessary.&lt;/p&gt;

&lt;p&gt;NOTE: the prefix &lt;code&gt;feature/*&lt;/code&gt; is the default, but if you or your team deem it necessary, you can adapt the prefix to anything else, for example &lt;code&gt;function/*&lt;/code&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  ⭐ release
&lt;/h4&gt;

&lt;p&gt;The &lt;code&gt;release&lt;/code&gt; branch is used to regroup the functionalities and corrections made, to prepare for the release of the version in development. This branch starts from &lt;code&gt;develop&lt;/code&gt; and must be &lt;code&gt;merged&lt;/code&gt; in both &lt;code&gt;develop&lt;/code&gt; and &lt;code&gt;master&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The perfect time to create a &lt;code&gt;release&lt;/code&gt; branch is when the &lt;code&gt;develop&lt;/code&gt; branch &lt;em&gt;looks&lt;/em&gt; as much as possible to what we want to have in production, it provides then a moment to make last minute corrections that we may have forgotten, or to make changes of the project that do not necessarily need a whole branch to be carried out, for example to increase the version number.&lt;/p&gt;

&lt;p&gt;Following Git-Flow, &lt;code&gt;release&lt;/code&gt; branches also have a prefix, &lt;code&gt;release/*&lt;/code&gt; or &lt;code&gt;release-*&lt;/code&gt;, usually followed by the version number or name they represent, for example: &lt;code&gt;release/1.2.0&lt;/code&gt; or &lt;code&gt;release/5.0&lt;/code&gt; or &lt;code&gt;release/1.0.0-rc.1+build.123&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The advantage of having a release branch is that work can continue in &lt;code&gt;develop&lt;/code&gt; and we can create other new &lt;code&gt;feature&lt;/code&gt; branches, since the planned work is already in the release one and will &lt;del&gt;should&lt;/del&gt; not have major changes.&lt;/p&gt;

&lt;h4&gt;
  
  
  🛠️ hotfix
&lt;/h4&gt;

&lt;p&gt;The &lt;code&gt;hotfix&lt;/code&gt; branches come from &lt;code&gt;master&lt;/code&gt; and must be &lt;code&gt;merged&lt;/code&gt; back in &lt;code&gt;master&lt;/code&gt; and &lt;code&gt;develop&lt;/code&gt;. They are used to make quick or critical corrections to the project, in order to publish a new version as soon as possible.&lt;/p&gt;

&lt;p&gt;NOTE: If you create a &lt;code&gt;hotfix&lt;/code&gt; branch but there is already a &lt;code&gt;release&lt;/code&gt; branch, instead of doing the &lt;code&gt;merge&lt;/code&gt; in &lt;code&gt;develop&lt;/code&gt;, it must be &lt;code&gt;merged&lt;/code&gt; in &lt;code&gt;master&lt;/code&gt; and &lt;code&gt;release&lt;/code&gt; instead.&lt;/p&gt;

&lt;h4&gt;
  
  
  ⚔️ hotfix vs bugfix
&lt;/h4&gt;

&lt;p&gt;In some projects we can see that in addition to the &lt;code&gt;hotfix&lt;/code&gt; branches, sometimes we have some branches with the &lt;code&gt;bugfix&lt;/code&gt; prefix. The difference between these two types of branches is that the &lt;code&gt;bugfix&lt;/code&gt; ones behave like &lt;code&gt;features&lt;/code&gt; and the &lt;code&gt;hotfix&lt;/code&gt; ones behave like &lt;code&gt;releases&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;In other words, we can use the &lt;code&gt;bugfixes&lt;/code&gt; to make minor bug fixes that can wait for the release of the development version, while the &lt;code&gt;hotfixes&lt;/code&gt; cannot wait and should be published as soon as the development has been approved.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;✔️ bugfix/fix-some-thingy-that-almost-nobody-uses-and-its-not-really-important
✔️ hotfix/fix-clic-on-top-right-corner-of-login-button-sets-the-users-computer-on-fire
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  ✏️ Tutorial &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;For this tutorial and in order to simplify it, I will use the Git-Flow console plugin of &lt;a href="https://github.com/petervanderdoes/gitflow-avh" rel="noopener noreferrer"&gt;Peter van der Does&lt;/a&gt;, but you can also see the equivalent &lt;a href="https://gist.github.com/JamesMGreene/cdd0ac49f90c987e45ac" rel="noopener noreferrer"&gt;classic Git commands&lt;/a&gt; to Git-Flow commands.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Initialize Git-Flow in the project&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Initialize Git in the project, create the develop branch and
# configure the prefixes of the other branches.
# Then, switch to the develop branch
git flow init
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F5ush55zzd9oaqorna9pf.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F5ush55zzd9oaqorna9pf.gif" alt="git flow init"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Starting to work on a new feature&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Creates a new feature/* branch and starts pointing to it
git flow feature start &amp;lt;feature-name&amp;gt;
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fdw1ll43xgdzzncqpxxt2.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fdw1ll43xgdzzncqpxxt2.gif" alt="git flow feature start"&gt;&lt;/a&gt;&lt;br&gt;
We can see how the console tells us the actions performed and that we can start working on the new branch.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Finish a feature&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# The name of the feature is optional, not really necessary if
# you are already on the branch.
# Changes to develop, performs a merge of the feature to develop
# And deletes the feature branch
git flow feature finish &amp;lt;feature-name&amp;gt;
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F7twy4bwoq6r4m2dr7edc.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F7twy4bwoq6r4m2dr7edc.gif" alt="git flow feature finish"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;NOTE: All these actions are performed in your local repository, nothing is done in the distant one, unless you &lt;code&gt;push&lt;/code&gt; the branches. Always remember to &lt;code&gt;push&lt;/code&gt; when you finish your features, to update &lt;code&gt;develop&lt;/code&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Prepare for the new version&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Creates a new release/* branch from develop y change the pointer to it
git flow release start &amp;lt;version-name&amp;gt;
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fxa9tsuaqyghc0lzxzya4.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fxa9tsuaqyghc0lzxzya4.gif" alt="git flow release start"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;NOTE: Right after updating the version number of your project it is a good time to publish the release branch in &lt;code&gt;origin&lt;/code&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Finishing the release&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Checks out the master branch
# Merges the release in master
# Creates the version tag using the name of the release branch
# Checks out the develop branch
# Merges the release in develop
# Deletes the release branch
git flow release finish

# Don't forget to push!
git push origin master
git push origin develop
git push --tags
git push origin :release/1.2.0 (if the release was in the distant repo)
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F9wnd7eyv1kd44hrtgkkl.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F9wnd7eyv1kd44hrtgkkl.gif" alt="git flow release finish"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Creating a hotfix&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# A hotfix branch may be created from a specific commit or from the last commit if not specified.
# Creates a hotfix branch and checks it out
git flow hotfix start &amp;lt;hotfix-name&amp;gt; [&amp;lt;commit&amp;gt;]
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fzk7rio07c4kouvbfkxej.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fzk7rio07c4kouvbfkxej.gif" alt="git flow hotfix start"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Finish a hotfix&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Same behavior as the release branches
# You can also specify the option -T or --tagname
# to create the tag correctly if the name of your
# hotfix branch is not a version number.
git flow hotfix finish [&amp;lt;-T version-name&amp;gt;]
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Ffoisegiro6knb6bse4ag.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Ffoisegiro6knb6bse4ag.gif" alt="git flow hotfix finish"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Next steps
&lt;/h2&gt;

&lt;p&gt;For the next article, we will talk about other strategies, but if you want to learn more about Git-Flow at the moment, here are some sources that I used for this article.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://nvie.com/posts/a-successful-git-branching-model/" rel="noopener noreferrer"&gt;A successul Git branching model&lt;/a&gt;: The original article from the author of Git-Flow&lt;br&gt;
&lt;a href="https://danielkummer.github.io/git-flow-cheatsheet/" rel="noopener noreferrer"&gt;Git-Flow cheat sheet&lt;/a&gt;: The essential Git-Flow cheat sheet&lt;br&gt;
&lt;a href="https://www.endoflineblog.com/gitflow-considered-harmful" rel="noopener noreferrer"&gt;GitFlow considered harmful&lt;/a&gt;: A simpler alternative to Git-Flow and the subject of my next article.&lt;/p&gt;

</description>
      <category>git</category>
      <category>beginners</category>
      <category>gitflow</category>
      <category>versioning</category>
    </item>
    <item>
      <title>☕ Git-Flow: Lo Esencial</title>
      <dc:creator>Fernando Ayon</dc:creator>
      <pubDate>Mon, 08 Jun 2020 09:47:40 +0000</pubDate>
      <link>https://dev.to/fernando_ayon/git-flow-lo-esencial-3bgf</link>
      <guid>https://dev.to/fernando_ayon/git-flow-lo-esencial-3bgf</guid>
      <description>&lt;p&gt;🇬🇧 &lt;a href="https://dev.to/fernando_ayon/git-flow-an-introduction-430m"&gt;English version&lt;/a&gt;&lt;br&gt;
🇫🇷 &lt;a href="https://dev.to/fernando_ayon/git-flow-premiers-pas-e93"&gt;Version française&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;¿Tienes un nuevo empleo o en tu trabajo actual están planeando implementar Git-Flow y no sabes de qué se trata?&lt;/p&gt;

&lt;p&gt;Has venido al lugar indicado. En este post te lo explico, pero si ya lo conoces un poco y solo quieres indicaciones sobre su uso, salta al tutorial.&lt;/p&gt;
&lt;h1&gt;
  
  
  🧐 Contexto
&lt;/h1&gt;

&lt;p&gt;En pocas palabras, &lt;a href="https://git-scm.com/" rel="noopener noreferrer"&gt;Git&lt;/a&gt; es un sistema de gestión de versiones, es una herramienta indispensable para controlar el ciclo de vida del desarrollo de una aplicación.&lt;/p&gt;

&lt;p&gt;Hasta aquí todo bien, pero los problemas empiezan a aparecer cuando se trabaja en equipo: tú y tu equipo podrían decidir de simplemente trabajar en la rama principal del proyecto y crear algunas ramas secundarias en ocasiones especiales, pero ¿qué pasa cuando hay mucho trabajo o varias personas deben trabajar en la misma función al mismo tiempo?&lt;/p&gt;
&lt;h2&gt;
  
  
  📓 &lt;a href="https://nvie.com/posts/a-successful-git-branching-model/" rel="noopener noreferrer"&gt;Git-Flow&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;Al trabajar en equipo, es necesario definir convenciones o buenas practicas para que todos sepan como trabajar juntos. Git-Flow es uno de muchos de los llamados &lt;em&gt;flujos de trabajo&lt;/em&gt;, bastante popular por su practicidad y aprendizaje relativamente rápido, es una manera de organizar las ramas del repositorio del proyecto.&lt;/p&gt;

&lt;p&gt;Probablemente ya has visto esta imagen o una parecida al buscar el término Git-Flow en Internet:&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F8uwtwsr8ktejnuh4rad6.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F8uwtwsr8ktejnuh4rad6.jpg" alt="*Visible confusion*"&gt;&lt;/a&gt; &lt;em&gt;Git-Flow en una imagen&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Parece y es complicado a primera vista, pero al conocer las diferentes ramas utilizadas y el por qué de su existencia veras que su funcionamiento es bastante lógico.&lt;/p&gt;
&lt;h3&gt;
  
  
  🌳 Ramas
&lt;/h3&gt;

&lt;p&gt;Como ya vimos en la imagen, Git-Flow utiliza varias ramas para organizar el desarrollo:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;master&lt;/li&gt;
&lt;li&gt;develop&lt;/li&gt;
&lt;li&gt;feature&lt;/li&gt;
&lt;li&gt;release&lt;/li&gt;
&lt;li&gt;hotfix&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;
  
  
  🌴 master y develop
&lt;/h4&gt;

&lt;p&gt;Si ya has utilizado Git antes, estarás familiarizado con la rama &lt;code&gt;master&lt;/code&gt;. En este nuevo contexto, esta rama es "intocable", nadie del equipo debe hacer ningún cambio directamente en ella, ni crear nuevas ramas a partir de ella, con una excepción que veremos más adelante.&lt;/p&gt;

&lt;p&gt;Al crear un nuevo proyecto, o al momento de comenzar a utilizar Git-Flow, la rama &lt;code&gt;develop&lt;/code&gt; debe ser creada a partir de &lt;code&gt;master&lt;/code&gt;, y al igual que &lt;code&gt;master&lt;/code&gt;, sera una rama de "larga duración de vida", es decir, nunca sera borrada y vivirá paralelamente a &lt;code&gt;master&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Como su nombre lo indica, la rama &lt;code&gt;develop&lt;/code&gt; sirve como base para desarrollar todas las nuevas funciones y correcciones del proyecto, por eso es considerada como la rama principal. &lt;/p&gt;

&lt;p&gt;Una vez que todas las nuevas funciones del proyecto han sido completadas y &lt;code&gt;develop&lt;/code&gt; es estable, debemos hacer un &lt;code&gt;merge&lt;/code&gt; de develop en &lt;code&gt;master&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;La rama &lt;code&gt;master&lt;/code&gt; debe reflejar siempre un estado 'en producción', por eso es importante que no realicemos cambios directamente en ella, ya que cada vez que hay un nuevo &lt;code&gt;commit&lt;/code&gt;, deberíamos hacer un &lt;code&gt;tag&lt;/code&gt; para definir la nueva versión y publicarla. &lt;/p&gt;
&lt;h4&gt;
  
  
  💯 feature
&lt;/h4&gt;

&lt;p&gt;Las ramas &lt;code&gt;feature&lt;/code&gt; son aquellas que dedicamos completamente al desarrollo de cada una de las nuevas funciones que agregaremos al proyecto en la versión siguiente. Siempre parten de &lt;code&gt;develop&lt;/code&gt; y debemos hacer el &lt;code&gt;merge&lt;/code&gt; de regreso a &lt;code&gt;develop&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;Si seguimos las buenas practicas de Git-Flow, al crear una nueva rama &lt;code&gt;feature&lt;/code&gt;, siempre debemos agregar el prefijo &lt;code&gt;feature/&lt;/code&gt;, de esta manera podemos mantener una buena organización y al ver las ramas activas podremos identificar rápidamente el trabajo en curso. &lt;/p&gt;

&lt;p&gt;Al mismo tiempo, es importante nombrar las ramas &lt;code&gt;feature&lt;/code&gt; de una forma descriptiva que permita identificar la finalidad de la rama:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;❌ feature/new-method
✔️ feature/add-support-for-json-parsing
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Lo importante de las ramas feature es que vivan solamente durante el desarrollo y que desaparezcan una vez que hayamos realizado el &lt;code&gt;merge&lt;/code&gt; en &lt;code&gt;develop&lt;/code&gt; o que sean descartadas si la función ya no es necesaria.&lt;/p&gt;

&lt;p&gt;NOTA: el prefijo &lt;code&gt;feature/*&lt;/code&gt; es la practica por defecto, pero si tu o tu equipo lo estiman necesario, pueden adaptar el prefijo a cualquier otra cosa, por ejemplo &lt;code&gt;funcionalidad/...&lt;/code&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  ⭐ release
&lt;/h4&gt;

&lt;p&gt;La rama &lt;code&gt;release&lt;/code&gt; sirve para reagrupar las funcionalidades y correcciones efectuadas para poder preparar el lanzamiento de la versión en desarrollo. Esta rama parte de &lt;code&gt;develop&lt;/code&gt; y el &lt;code&gt;merge&lt;/code&gt; se hace tanto en &lt;code&gt;develop&lt;/code&gt; como en &lt;code&gt;master&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;El momento perfecto para crear las ramas &lt;code&gt;release&lt;/code&gt; es cuando la rama &lt;code&gt;develop&lt;/code&gt; se asemeja lo mas posible a lo que queremos tener en producción, es una manera para poder hacer las correcciones de ultimo minuto que pudimos haber olvidado, o para realizar cambios del proyecto que no necesariamente necesitan toda una rama para ser realizados, por ejemplo para aumentar el numero de versión.&lt;/p&gt;

&lt;p&gt;Siguiendo las practicas de Git-Flow, las ramas &lt;code&gt;release&lt;/code&gt; también tienen un prefijo, &lt;code&gt;release/*&lt;/code&gt; o &lt;code&gt;release-*&lt;/code&gt;, normalmente seguido del numero o nombre de la versión que representan, por ejemplo: &lt;code&gt;release/1.2.0&lt;/code&gt; o &lt;code&gt;release/5.0&lt;/code&gt; o &lt;code&gt;release/1.0.0-rc.1+build.123&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;La ventaja de tener una rama release es que el trabajo puede continuar en &lt;code&gt;develop&lt;/code&gt; y otras nuevas ramas &lt;code&gt;feature&lt;/code&gt;, ya que el trabajo planeado ya se encuentra en la release y no va a tener cambios importantes.&lt;/p&gt;

&lt;h4&gt;
  
  
  🛠️ hotfix
&lt;/h4&gt;

&lt;p&gt;Las ramas &lt;code&gt;hotfix&lt;/code&gt; parten de &lt;code&gt;master&lt;/code&gt; y debemos realizar el &lt;code&gt;merge&lt;/code&gt; de vuelta en &lt;code&gt;master&lt;/code&gt; y &lt;code&gt;develop&lt;/code&gt;. Son utilizadas para realizar correcciones rápidas al proyecto, para poder publicar una nueva version lo antes posible. &lt;/p&gt;

&lt;p&gt;NOTA: Si creamos una rama &lt;code&gt;hotfix&lt;/code&gt; pero ya existe una rama &lt;code&gt;release&lt;/code&gt;, en lugar de hacer el &lt;code&gt;merge&lt;/code&gt; en &lt;code&gt;develop&lt;/code&gt;, debemos hacer el &lt;code&gt;merge&lt;/code&gt; en &lt;code&gt;master&lt;/code&gt; y &lt;code&gt;release&lt;/code&gt;.&lt;/p&gt;

&lt;h4&gt;
  
  
  ⚔️ hotfix vs bugfix
&lt;/h4&gt;

&lt;p&gt;En algunos proyectos podemos ver que ademas de las ramas &lt;code&gt;hotfix&lt;/code&gt;, a veces tenemos algunas con el prefijo &lt;code&gt;bugfix&lt;/code&gt;. La diferencia entre estos dos tipos de ramas es que las &lt;code&gt;bugfix&lt;/code&gt; se comportan como las &lt;code&gt;feature&lt;/code&gt; y las &lt;code&gt;hotfix&lt;/code&gt; se comportan como las &lt;code&gt;release&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Visto de otra manera, podemos utilizar las &lt;code&gt;bugfix&lt;/code&gt; para realizar correcciones de bugs no muy importantes que pueden esperar al lanzamiento de la versión en desarrollo, mientras que las &lt;code&gt;hotfix&lt;/code&gt; no pueden esperar y deben ser publicadas en cuanto el desarrollo haya sido aprobado.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;✔️ bugfix/fix-some-thingy-that-almost-nobody-uses-and-its-not-really-important
✔️ hotfix/fix-clic-on-top-right-corner-of-login-button-sets-the-users-computer-on-fire
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  ✏️ Tutorial &lt;a&gt;&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Para este tutorial y con el fin de simplificarlo al maximo, utilizaré el plugin para consola de Git-Flow de &lt;a href="https://github.com/petervanderdoes/gitflow-avh" rel="noopener noreferrer"&gt;Peter van der Does&lt;/a&gt;, pero aquí te dejo los &lt;a href="https://gist.github.com/JamesMGreene/cdd0ac49f90c987e45ac" rel="noopener noreferrer"&gt;comandos clásicos Git equivalentes&lt;/a&gt; a los comandos de Git-Flow.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Habilitar Git-Flow en el proyecto&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Inicia Git en el proyecto, crea la rama develop y 
# configura los prefijos de las otras ramas.
# Finalmente, cambia a la rama develop
git flow init
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F5ush55zzd9oaqorna9pf.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F5ush55zzd9oaqorna9pf.gif" alt="git flow init"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Comenzar a trabajar en una nueva funcionalidad&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Crear una nueva rama feature/* y cambiarse a ella
git flow feature start &amp;lt;feature-name&amp;gt;
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fdw1ll43xgdzzncqpxxt2.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fdw1ll43xgdzzncqpxxt2.gif" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
Podemos ver como la consola nos dice las acciones efectuadas y que podemos comenzar a trabajar en la nueva rama.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Terminar una funcionalidad&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# El nombre de la feature es opcional, no es necesario si
# ya nos encontramos en la rama.
# Cambia a develop, hace un merge de la feature hacia develop
# Y elimina la rama feature
git flow feature finish &amp;lt;feature-name&amp;gt;
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F7twy4bwoq6r4m2dr7edc.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F7twy4bwoq6r4m2dr7edc.gif" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;NOTA: Todas estas acciones son realizadas en tu repositorio local, nada en el distante, a menos que realices un &lt;code&gt;push&lt;/code&gt;. Recuerda hacerlo al terminar tus features, para actualizar &lt;code&gt;develop&lt;/code&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Preparar la nueva versión&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Crea una nueva rama release/* desde develop y cambia a ella.
git flow release start &amp;lt;version-name&amp;gt;
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fxa9tsuaqyghc0lzxzya4.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fxa9tsuaqyghc0lzxzya4.gif" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;NOTA: Justo después de actualizar el numero de versión de tu proyecto es un buen momento para publicar la rama release en &lt;code&gt;origin&lt;/code&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Terminar la versión&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Cambia a la rama master
# Hace un merge de la release
# Crea el tag de la versión utilizando el nombre de la rama
# Cambia a la rama develop
# Hace un merge de la release
# Elimina la rama release
git flow release finish

# No olvides enviar los últimos cambios a `origin` utilizando los comandos clásicos de Git
git push origin master
git push origin develop
git push --tags
git push origin :release/1.2.0 (si la release estaba en el repo distante)
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F9wnd7eyv1kd44hrtgkkl.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F9wnd7eyv1kd44hrtgkkl.gif" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Crear un hotfix&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Puede ser creada a partir de un commit específico o simplemente del ultimo existente.
# Crea una rama hotfix y cambia a ella
git flow hotfix start &amp;lt;hotfix-name&amp;gt; [&amp;lt;commit&amp;gt;]
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fzk7rio07c4kouvbfkxej.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fzk7rio07c4kouvbfkxej.gif" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Finalizar un hotfix&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Ocurre lo mismo que en una release
# No olvides especificar el argumento -T o --tagname
# para crear un tag correctamente si el nombre de tu
# rama hotfix no es un numero de versión.
git flow hotfix finish [&amp;lt;-T version-name&amp;gt;]
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Ffoisegiro6knb6bse4ag.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Ffoisegiro6knb6bse4ag.gif" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Siguientes pasos
&lt;/h2&gt;

&lt;p&gt;En un siguiente articulo, hablaremos de otras estrategias, pero si por el momento quieres aprender mas sobre Git-Flow, aquí te dejo algunas fuentes que utilicé para este articulo.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://nvie.com/posts/a-successful-git-branching-model/" rel="noopener noreferrer"&gt;A successul Git branching model&lt;/a&gt;: El articulo original del creador de Git-Flow&lt;br&gt;
&lt;a href="https://danielkummer.github.io/git-flow-cheatsheet/" rel="noopener noreferrer"&gt;Git-Flow cheat sheet&lt;/a&gt;: Un vistazo rápido sobre los comandos de Git-Flow&lt;br&gt;
&lt;a href="https://www.endoflineblog.com/gitflow-considered-harmful" rel="noopener noreferrer"&gt;GitFlow considered harmful&lt;/a&gt;: Una alternativa mas simple a Git-Flow y una probada de lo que vamos a ver en el próximo articulo.&lt;/p&gt;

</description>
      <category>git</category>
      <category>beginners</category>
      <category>gitflow</category>
      <category>versioning</category>
    </item>
  </channel>
</rss>
