GitTrucsEtAstuces » Historique » Version 3
Daniel Dehennin, 13/12/2011 11:20
Amélioration de l’explication des objectifs
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 | 3 | Daniel Dehennin | Montrer au monde une ligne de développement cohérente et compréhensible. |
8 | 1 | Daniel Dehennin | |
9 | 3 | Daniel Dehennin | Cela se fait en deux temps : |
10 | 3 | Daniel Dehennin | # Identifier les modifications le plus finement possible lors du développement |
11 | 3 | Daniel Dehennin | # Grouper les modifications de façon logique pour la publication |
12 | 1 | Daniel Dehennin | |
13 | 3 | Daniel Dehennin | Lors du développement, on va faire des commits le plus souvent possible, cela permet de _voir_ et _aggencer_ les évolutions au cours du développement. |
14 | 3 | Daniel Dehennin | |
15 | 3 | Daniel Dehennin | Afin de ne pas se surcharger inutilement et donc se décourager à faire des commits souvent, on pourra faire une exception [[GitBonnesPratiques#De-l’écriture-des-ChangeLog|à la bonne écriture des ChangeLogs]] sur ces branches privées dédiées au développement et utiliser l’option *-m* de @git commit@. |
16 | 3 | Daniel Dehennin | |
17 | 3 | Daniel Dehennin | En revanche, avant la publication, il faut tout remettre en ordre : |
18 | 3 | Daniel Dehennin | * Regrouper les commits entre eux de façon logique |
19 | 3 | Daniel Dehennin | * Réécrire les [[GitBonnesPratiques#De-l’écriture-des-ChangeLog|ChangeLog]] |
20 | 3 | Daniel Dehennin | |
21 | 1 | Daniel Dehennin | h2. N’ayons peur de rien, balisons ! |
22 | 3 | Daniel Dehennin | |
23 | 3 | Daniel Dehennin | L’écriture de [[GitBonnesPratiques#De-l’écriture-des-ChangeLog|ChangeLog]] sur une seule ligne nous fait perdre de l’information, on se contentera donc du minimum nécessaire afin de s’y retrouver lors de la phase de réécriture des [[GitBonnesPratiques#De-l’écriture-des-ChangeLog|ChangeLog]] : |
24 | 3 | Daniel Dehennin | # La raison de la modification du commit |
25 | 3 | Daniel Dehennin | # Une balise pour cataloguer ce commit |
26 | 3 | Daniel Dehennin | |
27 | 3 | 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 : |
28 | 3 | Daniel Dehennin | * Corriger tout ce que l’on voit, si personne d’autre ne l’a déjà fait, alors ça sera fait |
29 | 3 | Daniel Dehennin | * Ne pas se donner du travail supplémentaire à gérer des conflits pour des corrections typographiques et/ou mineures. |
30 | 1 | Daniel Dehennin | |
31 | 1 | Daniel Dehennin | h3. Les commits de notre code |
32 | 1 | Daniel Dehennin | |
33 | 1 | Daniel Dehennin | Différents types de commit : |
34 | 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 ;-) ; |
35 | 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 ] ; |
36 | 1 | Daniel Dehennin | * Le commit qui corrige un problème cosmétique (C: Cosmetic) de notre travail, décomposé en 2 sous catégories : |
37 | 1 | Daniel Dehennin | ** La correction des messages visibles par l’utilisateur (C: print:) ; |
38 | 1 | Daniel Dehennin | ** La correction des commentaires (C: #:). |
39 | 1 | Daniel Dehennin | |
40 | 1 | Daniel Dehennin | Voici un exemple type de messages de log court pour une nouvelle fonctionnalitée : |
41 | 1 | Daniel Dehennin | <pre> |
42 | 1 | Daniel Dehennin | moi@work:~/src/bidule(moi/voyant-qui-clignote)$ git log --oneline master..HEAD |
43 | 1 | Daniel Dehennin | ed002ff N: Ajout de la bibilothèque de gestion du voyant qui clignote |
44 | 1 | Daniel Dehennin | 7610ac6 F: Oublie d’une ) lors de l’appel à ->new() |
45 | 1 | Daniel Dehennin | c44649d C: #: Mauvaise tournure de phrase: le voyant qui clignote est obligatoire |
46 | 1 | Daniel Dehennin | 2ed9b43 C: print: Typo: 3e personne du pluriel == ent |
47 | 1 | Daniel Dehennin | </pre> |
48 | 1 | Daniel Dehennin | |
49 | 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]] : |
50 | 1 | Daniel Dehennin | * Les commit № 7610ac6, c44649d et 2ed9b43 doivent être fusionnées avec le commit № ed002ff et leur message de commit suprrimé |
51 | 1 | Daniel Dehennin | |
52 | 1 | Daniel Dehennin | h3. Les commits du code des autres |
53 | 1 | Daniel Dehennin | |
54 | 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. |
55 | 1 | Daniel Dehennin | |
56 | 1 | Daniel Dehennin | C’est à dire, la correction des problèmes qui étaient déjà présents avant de faire la nouvelle branche. |
57 | 1 | Daniel Dehennin | |
58 | 1 | Daniel Dehennin | * Le commit qui corrige un problème fonctionnel (Fo: Fix other) ; |
59 | 1 | Daniel Dehennin | * Le commit qui corrige un problème cosmétique (Co: Cosmetic other), décomposé en 2 sous catégories : |
60 | 1 | Daniel Dehennin | ** La correction des messages visibles par l’utilisateur (Co: print:) ; |
61 | 1 | Daniel Dehennin | ** La correction des commentaires (Co: #:). |
62 | 1 | Daniel Dehennin | |
63 | 1 | Daniel Dehennin | Il est ainsi aisé de savoir quels commits il faut fusionner et quels commits restent autonommes : |
64 | 1 | Daniel Dehennin | |
65 | 1 | Daniel Dehennin | <pre> |
66 | 1 | Daniel Dehennin | moi@work:~/src/bidule(moi/voyant-qui-clignote)$ git log --oneline master..HEAD |
67 | 1 | Daniel Dehennin | ed002ff N: Ajout de la bibilothèque de gestion du voyant qui clignote |
68 | 1 | Daniel Dehennin | 7610ac6 F: Oublie d’une ) lors de l’appel à ->new() |
69 | 1 | Daniel Dehennin | 74fe39b Co: #: Erreur de description de la variable "remote" de la méthode Bidule::Truc::Machiner() |
70 | 1 | Daniel Dehennin | c44649d C: #: Mauvaise tournure de phrase: le voyant qui clignote est obligatoire |
71 | 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 |
72 | 1 | Daniel Dehennin | 9a6c6c9 Co: print: Typo: Correction du message de l’exception Bidule::Exception::NoBattery |
73 | 1 | Daniel Dehennin | 2ed9b43 C: print: Typo: 3e personne du pluriel == ent |
74 | 1 | Daniel Dehennin | </pre> |
75 | 1 | Daniel Dehennin | |
76 | 1 | Daniel Dehennin | h2. Comment s’en servir ? |
77 | 1 | Daniel Dehennin | |
78 | 1 | Daniel Dehennin | Lors d’un @git rebase -i HEAD~7@, l’éditeur est lancé avec le contenu suivant : |
79 | 1 | Daniel Dehennin | <pre> |
80 | 1 | Daniel Dehennin | moi@work:~/src/bidule(moi/voyant-qui-clignote)$ git rebase -i HEAD~7 |
81 | 1 | Daniel Dehennin | pick ed002ff N: Ajout de la bibilothèque de gestion du voyant qui clignote |
82 | 1 | Daniel Dehennin | pick 7610ac6 F: Oublie d’une ) lors de l’appel à ->new() |
83 | 1 | Daniel Dehennin | pick 74fe39b Co: #: Erreur de description de la variable "remote" de la méthode Bidule::Truc::Machiner() |
84 | 1 | Daniel Dehennin | pick c44649d C: #: Mauvaise tournure de phrase: le voyant qui clignote est obligatoire |
85 | 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 |
86 | 1 | Daniel Dehennin | pick 9a6c6c9 Co: print: Typo: Correction du message de l’exception Bidule::Exception::NoBattery |
87 | 1 | Daniel Dehennin | pick 2ed9b43 C: print: Typo: 3e personne du pluriel == ent |
88 | 1 | Daniel Dehennin | # Rebase ed002ff..2ed9b43 onto ed002ff |
89 | 1 | Daniel Dehennin | # |
90 | 1 | Daniel Dehennin | # Commands: |
91 | 1 | Daniel Dehennin | # p, pick = use commit |
92 | 1 | Daniel Dehennin | # r, reword = use commit, but edit the commit message |
93 | 1 | Daniel Dehennin | # e, edit = use commit, but stop for amending |
94 | 1 | Daniel Dehennin | # s, squash = use commit, but meld into previous commit |
95 | 1 | Daniel Dehennin | # f, fixup = like "squash", but discard this commit's log message |
96 | 1 | Daniel Dehennin | # x, exec = run command (the rest of the line) using shell |
97 | 1 | Daniel Dehennin | # |
98 | 1 | Daniel Dehennin | # If you remove a line here THAT COMMIT WILL BE LOST. |
99 | 1 | Daniel Dehennin | # However, if you remove everything, the rebase will be aborted. |
100 | 1 | Daniel Dehennin | # |
101 | 1 | Daniel Dehennin | </pre> |
102 | 1 | Daniel Dehennin | |
103 | 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" : |
104 | 1 | Daniel Dehennin | |
105 | 1 | Daniel Dehennin | <pre> |
106 | 1 | Daniel Dehennin | moi@work:~/src/bidule(moi/voyant-qui-clignote)$ git rebase -i HEAD~7 |
107 | 1 | Daniel Dehennin | pick ed002ff N: Ajout de la bibilothèque de gestion du voyant qui clignote |
108 | 1 | Daniel Dehennin | f 7610ac6 F: Oublie d’une ) lors de l’appel à ->new() |
109 | 1 | Daniel Dehennin | f c44649d C: #: Mauvaise tournure de phrase: le voyant qui clignote est obligatoire |
110 | 1 | Daniel Dehennin | f 2ed9b43 C: print: Typo: 3e personne du pluriel == ent |
111 | 1 | Daniel Dehennin | pick 74fe39b Co: #: Erreur de description de la variable "remote" de la méthode Bidule::Truc::Machiner() |
112 | 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 |
113 | 1 | Daniel Dehennin | pick 9a6c6c9 Co: print: Typo: Correction du message de l’exception Bidule::Exception::NoBattery |
114 | 1 | Daniel Dehennin | # Rebase ed002ff..2ed9b43 onto ed002ff |
115 | 1 | Daniel Dehennin | # |
116 | 1 | Daniel Dehennin | # Commands: |
117 | 1 | Daniel Dehennin | # p, pick = use commit |
118 | 1 | Daniel Dehennin | # r, reword = use commit, but edit the commit message |
119 | 1 | Daniel Dehennin | # e, edit = use commit, but stop for amending |
120 | 1 | Daniel Dehennin | # s, squash = use commit, but meld into previous commit |
121 | 1 | Daniel Dehennin | # f, fixup = like "squash", but discard this commit's log message |
122 | 1 | Daniel Dehennin | # x, exec = run command (the rest of the line) using shell |
123 | 1 | Daniel Dehennin | # |
124 | 1 | Daniel Dehennin | # If you remove a line here THAT COMMIT WILL BE LOST. |
125 | 1 | Daniel Dehennin | # However, if you remove everything, the rebase will be aborted. |
126 | 1 | Daniel Dehennin | # |
127 | 1 | Daniel Dehennin | </pre> |
128 | 1 | Daniel Dehennin | |
129 | 1 | Daniel Dehennin | Une fois la mise au propre de notre historique faite, nous souhaitons publier ces modifications. |
130 | 1 | Daniel Dehennin | |
131 | 1 | Daniel Dehennin | Nous allons donc rebaser notre travail sur la branche @origin/master@ : |
132 | 1 | Daniel Dehennin | |
133 | 1 | Daniel Dehennin | # On commence par télécharger les éventuels modifications : |
134 | 1 | Daniel Dehennin | <pre> |
135 | 1 | Daniel Dehennin | moi@work:~/src/bidule(moi/voyant-qui-clignote)$ git fetch origin |
136 | 1 | Daniel Dehennin | remote: Counting objects: 24, done. |
137 | 1 | Daniel Dehennin | remote: Compressing objects: 100% (15/15), done. |
138 | 1 | Daniel Dehennin | remote: Total 15 (delta 12), reused 0 (delta 0) |
139 | 1 | Daniel Dehennin | Unpacking objects: 100% (15/15), done. |
140 | 1 | Daniel Dehennin | From git://far-far.away.example.net/bidule.git |
141 | 1 | Daniel Dehennin | 7ced305..9171f31 master -> origin/master |
142 | 1 | Daniel Dehennin | </pre> |
143 | 1 | Daniel Dehennin | # On rebase en modifiant les messages de commit afin de supprimer le balisage, il n’y a rien à fusionner : |
144 | 1 | Daniel Dehennin | <pre> |
145 | 1 | Daniel Dehennin | moi@work:~/src/bidule(moi/voyant-qui-clignote)$ git rebase origin/master |
146 | 1 | Daniel Dehennin | r ed002ff N: Ajout de la bibilothèque de gestion du voyant qui clignote |
147 | 1 | Daniel Dehennin | r 74fe39b Co: #: Erreur de description de la variable "remote" de la méthode Bidule::Truc::Machiner() |
148 | 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 |
149 | 1 | Daniel Dehennin | r 9a6c6c9 Co: print: Typo: Correction du message de l’exception Bidule::Exception::NoBattery |
150 | 1 | Daniel Dehennin | # Rebase ed002ff..9a6c6c9 onto 9171f31 |
151 | 1 | Daniel Dehennin | # |
152 | 1 | Daniel Dehennin | # Commands: |
153 | 1 | Daniel Dehennin | # p, pick = use commit |
154 | 1 | Daniel Dehennin | # r, reword = use commit, but edit the commit message |
155 | 1 | Daniel Dehennin | # e, edit = use commit, but stop for amending |
156 | 1 | Daniel Dehennin | # s, squash = use commit, but meld into previous commit |
157 | 1 | Daniel Dehennin | # f, fixup = like "squash", but discard this commit's log message |
158 | 1 | Daniel Dehennin | # x, exec = run command (the rest of the line) using shell |
159 | 1 | Daniel Dehennin | # |
160 | 1 | Daniel Dehennin | # If you remove a line here THAT COMMIT WILL BE LOST. |
161 | 1 | Daniel Dehennin | # However, if you remove everything, the rebase will be aborted. |
162 | 1 | Daniel Dehennin | # |
163 | 1 | Daniel Dehennin | </pre> |
164 | 1 | Daniel Dehennin | |
165 | 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*, |
166 | 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. |