GitTrucsEtAstuces » Historique » Version 2
Daniel Dehennin, 06/12/2011 20:49
C: typo: tournure de phrase alambiquée
| 1 | 1 | Daniel Dehennin | {{toc}} |
|---|---|---|---|
| 2 | 1 | Daniel Dehennin | |
| 3 | 1 | Daniel Dehennin | h1. Tu balises quand tu commit ? |
| 4 | 1 | Daniel Dehennin | |
| 5 | 1 | Daniel Dehennin | h2. Objectif |
| 6 | 1 | Daniel Dehennin | |
| 7 | 1 | Daniel Dehennin | L’idéal est de faire des commits : |
| 8 | 1 | Daniel Dehennin | * Souvent |
| 9 | 1 | Daniel Dehennin | * Par type de modification |
| 10 | 1 | Daniel Dehennin | |
| 11 | 1 | Daniel Dehennin | On peut ainsi mettre de côter des commits qui ne font que corriger des typos dans du code qui n’est pas le nôtre, l’idée est : |
| 12 | 1 | Daniel Dehennin | * Corriger tout ce que l’on voit, si personne d’autre ne l’a déjà fait, alors ça sera fait |
| 13 | 1 | Daniel Dehennin | * Ne pas se donner du travail supplémentaire à gérer des conflits pour des corrections typographiques et/ou mineures. |
| 14 | 1 | Daniel Dehennin | |
| 15 | 1 | Daniel Dehennin | h2. N’ayons peur de rien, balisons ! |
| 16 | 1 | Daniel Dehennin | |
| 17 | 1 | Daniel Dehennin | h3. Les commits de notre code |
| 18 | 1 | Daniel Dehennin | |
| 19 | 1 | Daniel Dehennin | Différents types de commit : |
| 20 | 2 | Daniel Dehennin | * Le commit qui introduisent de nouvelles choses (N: New) : quand on est super fort, on ne fait que ce type de commits, mais quand on est super fort, on a pas besoin de git ;-) ; |
| 21 | 1 | Daniel Dehennin | * Le commit qui corrige un problème fonctionnel dans le nouveau code introduit par le type ci-dessus (F: Fix) : et oui, ça arrive d’oublier des ", ) ou ] ; |
| 22 | 1 | Daniel Dehennin | * Le commit qui corrige un problème cosmétique (C: Cosmetic) de notre travail, décomposé en 2 sous catégories : |
| 23 | 1 | Daniel Dehennin | ** La correction des messages visibles par l’utilisateur (C: print:) ; |
| 24 | 1 | Daniel Dehennin | ** La correction des commentaires (C: #:). |
| 25 | 1 | Daniel Dehennin | |
| 26 | 1 | Daniel Dehennin | Voici un exemple type de messages de log court pour une nouvelle fonctionnalitée : |
| 27 | 1 | Daniel Dehennin | <pre> |
| 28 | 1 | Daniel Dehennin | moi@work:~/src/bidule(moi/voyant-qui-clignote)$ git log --oneline master..HEAD |
| 29 | 1 | Daniel Dehennin | ed002ff N: Ajout de la bibilothèque de gestion du voyant qui clignote |
| 30 | 1 | Daniel Dehennin | 7610ac6 F: Oublie d’une ) lors de l’appel à ->new() |
| 31 | 1 | Daniel Dehennin | c44649d C: #: Mauvaise tournure de phrase: le voyant qui clignote est obligatoire |
| 32 | 1 | Daniel Dehennin | 2ed9b43 C: print: Typo: 3e personne du pluriel == ent |
| 33 | 1 | Daniel Dehennin | </pre> |
| 34 | 1 | Daniel Dehennin | |
| 35 | 1 | Daniel Dehennin | Le balisage de chaque commit permet de facilement s’y retrouver lors de la réorganisation des commits pour [[GitBonnesPratiques#Publication-du-développement|publication]] : |
| 36 | 1 | Daniel Dehennin | * Les commit № 7610ac6, c44649d et 2ed9b43 doivent être fusionnées avec le commit № ed002ff et leur message de commit suprrimé |
| 37 | 1 | Daniel Dehennin | |
| 38 | 1 | Daniel Dehennin | h3. Les commits du code des autres |
| 39 | 1 | Daniel Dehennin | |
| 40 | 1 | Daniel Dehennin | Il est possible, et vivement recommandé par moi-même, d’introduire une autre série de balises pour tout ce qui est correction en dehors de notre travail en cours. |
| 41 | 1 | Daniel Dehennin | |
| 42 | 1 | Daniel Dehennin | C’est à dire, la correction des problèmes qui étaient déjà présents avant de faire la nouvelle branche. |
| 43 | 1 | Daniel Dehennin | |
| 44 | 1 | Daniel Dehennin | * Le commit qui corrige un problème fonctionnel (Fo: Fix other) ; |
| 45 | 1 | Daniel Dehennin | * Le commit qui corrige un problème cosmétique (Co: Cosmetic other), décomposé en 2 sous catégories : |
| 46 | 1 | Daniel Dehennin | ** La correction des messages visibles par l’utilisateur (Co: print:) ; |
| 47 | 1 | Daniel Dehennin | ** La correction des commentaires (Co: #:). |
| 48 | 1 | Daniel Dehennin | |
| 49 | 1 | Daniel Dehennin | Il est ainsi aisé de savoir quels commits il faut fusionner et quels commits restent autonommes : |
| 50 | 1 | Daniel Dehennin | |
| 51 | 1 | Daniel Dehennin | <pre> |
| 52 | 1 | Daniel Dehennin | moi@work:~/src/bidule(moi/voyant-qui-clignote)$ git log --oneline master..HEAD |
| 53 | 1 | Daniel Dehennin | ed002ff N: Ajout de la bibilothèque de gestion du voyant qui clignote |
| 54 | 1 | Daniel Dehennin | 7610ac6 F: Oublie d’une ) lors de l’appel à ->new() |
| 55 | 1 | Daniel Dehennin | 74fe39b Co: #: Erreur de description de la variable "remote" de la méthode Bidule::Truc::Machiner() |
| 56 | 1 | Daniel Dehennin | c44649d C: #: Mauvaise tournure de phrase: le voyant qui clignote est obligatoire |
| 57 | 1 | Daniel Dehennin | 9972b58 Fo: La méthode Bidule::Truc::Biduler() n’étant jamais utilisée, personne n’a vu qu’elle ne fonctionnait pas |
| 58 | 1 | Daniel Dehennin | 9a6c6c9 Co: print: Typo: Correction du message de l’exception Bidule::Exception::NoBattery |
| 59 | 1 | Daniel Dehennin | 2ed9b43 C: print: Typo: 3e personne du pluriel == ent |
| 60 | 1 | Daniel Dehennin | </pre> |
| 61 | 1 | Daniel Dehennin | |
| 62 | 1 | Daniel Dehennin | h2. Comment s’en servir ? |
| 63 | 1 | Daniel Dehennin | |
| 64 | 1 | Daniel Dehennin | Lors d’un @git rebase -i HEAD~7@, l’éditeur est lancé avec le contenu suivant : |
| 65 | 1 | Daniel Dehennin | <pre> |
| 66 | 1 | Daniel Dehennin | moi@work:~/src/bidule(moi/voyant-qui-clignote)$ git rebase -i HEAD~7 |
| 67 | 1 | Daniel Dehennin | pick ed002ff N: Ajout de la bibilothèque de gestion du voyant qui clignote |
| 68 | 1 | Daniel Dehennin | pick 7610ac6 F: Oublie d’une ) lors de l’appel à ->new() |
| 69 | 1 | Daniel Dehennin | pick 74fe39b Co: #: Erreur de description de la variable "remote" de la méthode Bidule::Truc::Machiner() |
| 70 | 1 | Daniel Dehennin | pick c44649d C: #: Mauvaise tournure de phrase: le voyant qui clignote est obligatoire |
| 71 | 1 | Daniel Dehennin | pick 9972b58 Fo: La méthode Bidule::Truc::Biduler() n’étant jamais utilisée, personne n’a vu qu’elle ne fonctionnait pas |
| 72 | 1 | Daniel Dehennin | pick 9a6c6c9 Co: print: Typo: Correction du message de l’exception Bidule::Exception::NoBattery |
| 73 | 1 | Daniel Dehennin | pick 2ed9b43 C: print: Typo: 3e personne du pluriel == ent |
| 74 | 1 | Daniel Dehennin | # Rebase ed002ff..2ed9b43 onto ed002ff |
| 75 | 1 | Daniel Dehennin | # |
| 76 | 1 | Daniel Dehennin | # Commands: |
| 77 | 1 | Daniel Dehennin | # p, pick = use commit |
| 78 | 1 | Daniel Dehennin | # r, reword = use commit, but edit the commit message |
| 79 | 1 | Daniel Dehennin | # e, edit = use commit, but stop for amending |
| 80 | 1 | Daniel Dehennin | # s, squash = use commit, but meld into previous commit |
| 81 | 1 | Daniel Dehennin | # f, fixup = like "squash", but discard this commit's log message |
| 82 | 1 | Daniel Dehennin | # x, exec = run command (the rest of the line) using shell |
| 83 | 1 | Daniel Dehennin | # |
| 84 | 1 | Daniel Dehennin | # If you remove a line here THAT COMMIT WILL BE LOST. |
| 85 | 1 | Daniel Dehennin | # However, if you remove everything, the rebase will be aborted. |
| 86 | 1 | Daniel Dehennin | # |
| 87 | 1 | Daniel Dehennin | </pre> |
| 88 | 1 | Daniel Dehennin | |
| 89 | 1 | Daniel Dehennin | Il est ainsi possible de *fusionner* les 4 commits qui nous conserne en un seul en déplaçant les lignes et en leur appliquant la commande de "fixup" : |
| 90 | 1 | Daniel Dehennin | |
| 91 | 1 | Daniel Dehennin | <pre> |
| 92 | 1 | Daniel Dehennin | moi@work:~/src/bidule(moi/voyant-qui-clignote)$ git rebase -i HEAD~7 |
| 93 | 1 | Daniel Dehennin | pick ed002ff N: Ajout de la bibilothèque de gestion du voyant qui clignote |
| 94 | 1 | Daniel Dehennin | f 7610ac6 F: Oublie d’une ) lors de l’appel à ->new() |
| 95 | 1 | Daniel Dehennin | f c44649d C: #: Mauvaise tournure de phrase: le voyant qui clignote est obligatoire |
| 96 | 1 | Daniel Dehennin | f 2ed9b43 C: print: Typo: 3e personne du pluriel == ent |
| 97 | 1 | Daniel Dehennin | pick 74fe39b Co: #: Erreur de description de la variable "remote" de la méthode Bidule::Truc::Machiner() |
| 98 | 1 | Daniel Dehennin | pick 9972b58 Fo: La méthode Bidule::Truc::Biduler() n’étant jamais utilisée, personne n’a vu qu’elle ne fonctionnait pas |
| 99 | 1 | Daniel Dehennin | pick 9a6c6c9 Co: print: Typo: Correction du message de l’exception Bidule::Exception::NoBattery |
| 100 | 1 | Daniel Dehennin | # Rebase ed002ff..2ed9b43 onto ed002ff |
| 101 | 1 | Daniel Dehennin | # |
| 102 | 1 | Daniel Dehennin | # Commands: |
| 103 | 1 | Daniel Dehennin | # p, pick = use commit |
| 104 | 1 | Daniel Dehennin | # r, reword = use commit, but edit the commit message |
| 105 | 1 | Daniel Dehennin | # e, edit = use commit, but stop for amending |
| 106 | 1 | Daniel Dehennin | # s, squash = use commit, but meld into previous commit |
| 107 | 1 | Daniel Dehennin | # f, fixup = like "squash", but discard this commit's log message |
| 108 | 1 | Daniel Dehennin | # x, exec = run command (the rest of the line) using shell |
| 109 | 1 | Daniel Dehennin | # |
| 110 | 1 | Daniel Dehennin | # If you remove a line here THAT COMMIT WILL BE LOST. |
| 111 | 1 | Daniel Dehennin | # However, if you remove everything, the rebase will be aborted. |
| 112 | 1 | Daniel Dehennin | # |
| 113 | 1 | Daniel Dehennin | </pre> |
| 114 | 1 | Daniel Dehennin | |
| 115 | 1 | Daniel Dehennin | Une fois la mise au propre de notre historique faite, nous souhaitons publier ces modifications. |
| 116 | 1 | Daniel Dehennin | |
| 117 | 1 | Daniel Dehennin | Nous allons donc rebaser notre travail sur la branche @origin/master@ : |
| 118 | 1 | Daniel Dehennin | |
| 119 | 1 | Daniel Dehennin | # On commence par télécharger les éventuels modifications : |
| 120 | 1 | Daniel Dehennin | <pre> |
| 121 | 1 | Daniel Dehennin | moi@work:~/src/bidule(moi/voyant-qui-clignote)$ git fetch origin |
| 122 | 1 | Daniel Dehennin | remote: Counting objects: 24, done. |
| 123 | 1 | Daniel Dehennin | remote: Compressing objects: 100% (15/15), done. |
| 124 | 1 | Daniel Dehennin | remote: Total 15 (delta 12), reused 0 (delta 0) |
| 125 | 1 | Daniel Dehennin | Unpacking objects: 100% (15/15), done. |
| 126 | 1 | Daniel Dehennin | From git://far-far.away.example.net/bidule.git |
| 127 | 1 | Daniel Dehennin | 7ced305..9171f31 master -> origin/master |
| 128 | 1 | Daniel Dehennin | </pre> |
| 129 | 1 | Daniel Dehennin | # On rebase en modifiant les messages de commit afin de supprimer le balisage, il n’y a rien à fusionner : |
| 130 | 1 | Daniel Dehennin | <pre> |
| 131 | 1 | Daniel Dehennin | moi@work:~/src/bidule(moi/voyant-qui-clignote)$ git rebase origin/master |
| 132 | 1 | Daniel Dehennin | r ed002ff N: Ajout de la bibilothèque de gestion du voyant qui clignote |
| 133 | 1 | Daniel Dehennin | r 74fe39b Co: #: Erreur de description de la variable "remote" de la méthode Bidule::Truc::Machiner() |
| 134 | 1 | Daniel Dehennin | r 9972b58 Fo: La méthode Bidule::Truc::Biduler() n’étant jamais utilisée, personne n’a vu qu’elle ne fonctionnait pas |
| 135 | 1 | Daniel Dehennin | r 9a6c6c9 Co: print: Typo: Correction du message de l’exception Bidule::Exception::NoBattery |
| 136 | 1 | Daniel Dehennin | # Rebase ed002ff..9a6c6c9 onto 9171f31 |
| 137 | 1 | Daniel Dehennin | # |
| 138 | 1 | Daniel Dehennin | # Commands: |
| 139 | 1 | Daniel Dehennin | # p, pick = use commit |
| 140 | 1 | Daniel Dehennin | # r, reword = use commit, but edit the commit message |
| 141 | 1 | Daniel Dehennin | # e, edit = use commit, but stop for amending |
| 142 | 1 | Daniel Dehennin | # s, squash = use commit, but meld into previous commit |
| 143 | 1 | Daniel Dehennin | # f, fixup = like "squash", but discard this commit's log message |
| 144 | 1 | Daniel Dehennin | # x, exec = run command (the rest of the line) using shell |
| 145 | 1 | Daniel Dehennin | # |
| 146 | 1 | Daniel Dehennin | # If you remove a line here THAT COMMIT WILL BE LOST. |
| 147 | 1 | Daniel Dehennin | # However, if you remove everything, the rebase will be aborted. |
| 148 | 1 | Daniel Dehennin | # |
| 149 | 1 | Daniel Dehennin | </pre> |
| 150 | 1 | Daniel Dehennin | |
| 151 | 1 | Daniel Dehennin | Si un conflit est détecté sur le commit *9a6c6c9 Co: print: Typo: Correction du message de l’exception Bidule::Exception::NoBattery*, |
| 152 | 1 | Daniel Dehennin | il suffira d’annuler le rebase avec @git rebase --abort@ et de le recommencer, cette fois ci en supprimant la ligne correspondante. |