GitBonnesPratiques » Historique » Version 9
Gaston TJEBBES, 03/05/2010 15:22
1 | 1 | Redmine Admin | {{toc}} |
---|---|---|---|
2 | 1 | Redmine Admin | |
3 | 1 | Redmine Admin | h1. Présentation |
4 | 1 | Redmine Admin | |
5 | 1 | Redmine Admin | Site officiel : http://git-scm.com/ |
6 | 1 | Redmine Admin | |
7 | 1 | Redmine Admin | Tutoriaux intéressants : |
8 | 1 | Redmine Admin | * http://team.gcu.info/~ange/git_article/ |
9 | 1 | Redmine Admin | * le tutorial des man pages http://www.kernel.org/pub/software/scm/git/docs/gittutorial.html |
10 | 1 | Redmine Admin | * http://gitready.com/ |
11 | 1 | Redmine Admin | * http://progit.org/book/ |
12 | 1 | Redmine Admin | * http://www.unixgarden.com/index.php/administration-systeme/git-pour-les-futurs-barbus |
13 | 7 | Gaston TJEBBES | * http://yannesposito.com/Scratch/fr/blog/2010-03-22-Git-Tips/ |
14 | 1 | Redmine Admin | |
15 | 1 | Redmine Admin | Les manpages des commandes sont accessibles avec la commande help directement, |
16 | 1 | Redmine Admin | par exemple : |
17 | 1 | Redmine Admin | <pre> |
18 | 1 | Redmine Admin | git help log |
19 | 1 | Redmine Admin | </pre> |
20 | 1 | Redmine Admin | |
21 | 6 | Redmine Admin | *remarque* : Il faut utiliser une version récente de git-core (>1.6.3) pour pouvoir travailler avec les dépôts. |
22 | 3 | samuel morin | |
23 | 1 | Redmine Admin | h1. Premiers pas |
24 | 1 | Redmine Admin | |
25 | 1 | Redmine Admin | Il est nécessaire de déclarer vos noms et emails dans votre configuration git globale |
26 | 1 | Redmine Admin | <pre> |
27 | 1 | Redmine Admin | git config --global user.name "Prénom NOM" |
28 | 1 | Redmine Admin | git config --global user.email "prenom.nom@ac-acad.fr" |
29 | 1 | Redmine Admin | </pre> |
30 | 1 | Redmine Admin | |
31 | 1 | Redmine Admin | * Commencer par récupérer un projet : |
32 | 1 | Redmine Admin | <pre> |
33 | 2 | samuel morin | git clone http://login@dev-eole.ac-dijon.fr/git/nom_projet |
34 | 1 | Redmine Admin | </pre>Cela va créer un répertoire @nom_projet@ contenant un répertoire @.git@. |
35 | 1 | Redmine Admin | |
36 | 1 | Redmine Admin | * Ajouter/retirer des fichiers : |
37 | 1 | Redmine Admin | <pre> |
38 | 1 | Redmine Admin | git add file1 file2 ... |
39 | 1 | Redmine Admin | git remove file1 file2 ... |
40 | 1 | Redmine Admin | </pre> |
41 | 1 | Redmine Admin | |
42 | 1 | Redmine Admin | * Pour savoir où l'on en est |
43 | 1 | Redmine Admin | <pre> |
44 | 1 | Redmine Admin | git status |
45 | 1 | Redmine Admin | </pre> |
46 | 1 | Redmine Admin | |
47 | 1 | Redmine Admin | * Enregistrer les modifications localement |
48 | 1 | Redmine Admin | <pre> |
49 | 1 | Redmine Admin | git commit -a -m"premiere version avec le scm git" |
50 | 1 | Redmine Admin | </pre> |
51 | 1 | Redmine Admin | |
52 | 1 | Redmine Admin | * Enregistrer les changements sur le serveur : |
53 | 1 | Redmine Admin | <pre> |
54 | 2 | samuel morin | git http-push http://login@dev-eole.ac-dijon.fr/git/nom_projet master |
55 | 1 | Redmine Admin | </pre> |
56 | 1 | Redmine Admin | *remarque* : Avant d'enregistrer les changements sur le serveur, pensez à éditer vos messages de commit, il est possible de les fusionner (Voir "Messages de commit"). |
57 | 1 | Redmine Admin | |
58 | 1 | Redmine Admin | * Pour se mettre à jour avant de faire des modifications : |
59 | 1 | Redmine Admin | <pre> |
60 | 1 | Redmine Admin | git checkout master |
61 | 1 | Redmine Admin | </pre> |
62 | 1 | Redmine Admin | |
63 | 1 | Redmine Admin | *remarque* le login doit être présent pour pouvoir être identifié lors du commit (voir "trucs et astuces" pour enregistrer vos logins/mot de passe) |
64 | 1 | Redmine Admin | |
65 | 1 | Redmine Admin | * Récupérer les modifications du serveur : |
66 | 1 | Redmine Admin | <pre> |
67 | 1 | Redmine Admin | git pull |
68 | 1 | Redmine Admin | </pre> |
69 | 1 | Redmine Admin | |
70 | 1 | Redmine Admin | |
71 | 1 | Redmine Admin | h1. Branch |
72 | 1 | Redmine Admin | |
73 | 1 | Redmine Admin | * Récupérer ou créer une branche |
74 | 1 | Redmine Admin | <pre> |
75 | 1 | Redmine Admin | git checkout -b mabranche |
76 | 1 | Redmine Admin | </pre> |
77 | 1 | Redmine Admin | |
78 | 1 | Redmine Admin | * Ceci peut être décomposé en 2 commandes : |
79 | 1 | Redmine Admin | <pre> |
80 | 1 | Redmine Admin | git branch mabranche |
81 | 1 | Redmine Admin | git checkout mabranche |
82 | 1 | Redmine Admin | </pre> |
83 | 1 | Redmine Admin | |
84 | 5 | Emmanuel GARETTE | * Diffuser la branche sur le serveur |
85 | 5 | Emmanuel GARETTE | <pre> |
86 | 5 | Emmanuel GARETTE | git http-push http://user@194.167.18.22/git/eolebase mabranche |
87 | 5 | Emmanuel GARETTE | </pre> |
88 | 5 | Emmanuel GARETTE | |
89 | 1 | Redmine Admin | * Supprimer une branche : |
90 | 1 | Redmine Admin | <pre> |
91 | 1 | Redmine Admin | git branch -D [nom-branche] |
92 | 1 | Redmine Admin | </pre> |
93 | 1 | Redmine Admin | |
94 | 1 | Redmine Admin | * Voir les différences entre deux branches |
95 | 1 | Redmine Admin | (par exemple avant de merger) : |
96 | 1 | Redmine Admin | <pre> |
97 | 1 | Redmine Admin | git diff-tree -p [nom-de-branche] |
98 | 1 | Redmine Admin | </pre> |
99 | 1 | Redmine Admin | |
100 | 1 | Redmine Admin | * Pour changer de branche : |
101 | 1 | Redmine Admin | <pre> |
102 | 1 | Redmine Admin | git checkout autrebranche |
103 | 1 | Redmine Admin | </pre> |
104 | 1 | Redmine Admin | |
105 | 1 | Redmine Admin | * Pour revenir à la branche principale : |
106 | 1 | Redmine Admin | <pre> |
107 | 1 | Redmine Admin | git checkout master |
108 | 1 | Redmine Admin | </pre> |
109 | 1 | Redmine Admin | |
110 | 1 | Redmine Admin | * Une autre technique consiste à organiser localement une arborescence différente par branche : |
111 | 1 | Redmine Admin | <pre> |
112 | 1 | Redmine Admin | git/master |
113 | 1 | Redmine Admin | /mabranche |
114 | 1 | Redmine Admin | </pre> |
115 | 1 | Redmine Admin | |
116 | 1 | Redmine Admin | * Savoir dans quelle branche on se trouve : |
117 | 1 | Redmine Admin | <pre> |
118 | 1 | Redmine Admin | git branch |
119 | 1 | Redmine Admin | </pre> |
120 | 1 | Redmine Admin | |
121 | 1 | Redmine Admin | * Voir la branche courante avec le dernier log : |
122 | 1 | Redmine Admin | <pre> |
123 | 1 | Redmine Admin | git show-branch |
124 | 1 | Redmine Admin | </pre> |
125 | 1 | Redmine Admin | |
126 | 8 | Gaston TJEBBES | * Envoyer pour la _première fois_ le contenu de la branche courante sur le serveur : |
127 | 8 | Gaston TJEBBES | <pre> |
128 | 8 | Gaston TJEBBES | git push origin HEAD |
129 | 8 | Gaston TJEBBES | </pre> |
130 | 8 | Gaston TJEBBES | |
131 | 8 | Gaston TJEBBES | Arrivé à ce stade il peut être intéressant d'utiliser @git-gui@ (@/usr/lib/git-core/git-gui@) ou @giggle@. |
132 | 8 | Gaston TJEBBES | |
133 | 8 | Gaston TJEBBES | Pour voir l'historique des différentes branches dans @guit-gui@, "@menu>dépôt>Voir l'historique de toutes les branches@" |
134 | 8 | Gaston TJEBBES | |
135 | 8 | Gaston TJEBBES | * Autres commandes de base : |
136 | 8 | Gaston TJEBBES | <pre> |
137 | 8 | Gaston TJEBBES | git log |
138 | 8 | Gaston TJEBBES | git log --pretty=oneline --all |
139 | 8 | Gaston TJEBBES | git diff |
140 | 8 | Gaston TJEBBES | </pre> |
141 | 8 | Gaston TJEBBES | |
142 | 8 | Gaston TJEBBES | |
143 | 7 | Gaston TJEBBES | h2. Branches distantes |
144 | 7 | Gaston TJEBBES | |
145 | 1 | Redmine Admin | * Si vous avez déjà cloné le master d'un projet, pour visualiser les branches disponibles : |
146 | 1 | Redmine Admin | <pre> |
147 | 1 | Redmine Admin | git branch -a |
148 | 1 | Redmine Admin | </pre> |
149 | 7 | Gaston TJEBBES | devrait renvoyer quelque chose comme ceci : |
150 | 7 | Gaston TJEBBES | <pre> |
151 | 1 | Redmine Admin | * master |
152 | 1 | Redmine Admin | remotes/origin/2.2 |
153 | 1 | Redmine Admin | remotes/origin/HEAD -> origin/master |
154 | 1 | Redmine Admin | remotes/origin/master |
155 | 1 | Redmine Admin | remotes/origin/upstream |
156 | 1 | Redmine Admin | </pre> |
157 | 1 | Redmine Admin | |
158 | 1 | Redmine Admin | * Pour récupérer la branche 2.2 : |
159 | 1 | Redmine Admin | <pre> |
160 | 1 | Redmine Admin | git branch --track 2.2 remotes/origin/2.2 |
161 | 1 | Redmine Admin | </pre> |
162 | 1 | Redmine Admin | |
163 | 1 | Redmine Admin | h1. Merge |
164 | 1 | Redmine Admin | |
165 | 1 | Redmine Admin | Fusion : action consistant à fusionner une branche avec une autre ("mabranche" avec @master@ par exemple) |
166 | 1 | Redmine Admin | |
167 | 1 | Redmine Admin | Exemple : @merge@ de la branche *mabranche* dans la branche *master* |
168 | 1 | Redmine Admin | |
169 | 1 | Redmine Admin | * Se placer dans la branche @master@ : |
170 | 1 | Redmine Admin | <pre> |
171 | 1 | Redmine Admin | git checkout master |
172 | 1 | Redmine Admin | git merge mabranche |
173 | 1 | Redmine Admin | git pull |
174 | 1 | Redmine Admin | </pre> |
175 | 1 | Redmine Admin | |
176 | 1 | Redmine Admin | *remarque* : après un @merge@, il n'y a pas de @commit@ à faire, juste @pull@. |
177 | 1 | Redmine Admin | |
178 | 1 | Redmine Admin | Si vous n'êtes pas satisfait du @merge@, il faut revenir en arrière avec un |
179 | 1 | Redmine Admin | <pre> |
180 | 1 | Redmine Admin | git reset --hard |
181 | 1 | Redmine Admin | </pre> |
182 | 1 | Redmine Admin | |
183 | 1 | Redmine Admin | **Résoudre un conflit de @merge@** |
184 | 1 | Redmine Admin | |
185 | 1 | Redmine Admin | Si lors d'un @merge@ il y a eu un problème du type : |
186 | 1 | Redmine Admin | <pre> |
187 | 1 | Redmine Admin | Auto-merged file.txt |
188 | 1 | Redmine Admin | CONFLICT (content): Merge conflict in file.txt |
189 | 1 | Redmine Admin | Automatic merge failed; fix conflicts and then commit the result. |
190 | 1 | Redmine Admin | </pre> et que |
191 | 1 | Redmine Admin | <pre> |
192 | 1 | Redmine Admin | git commit |
193 | 1 | Redmine Admin | </pre> répond qu'il reste des fichiers à merger (unresolved merge), *Il n'y a donc pas eu véritablement de commit* |
194 | 1 | Redmine Admin | de même qu'un |
195 | 1 | Redmine Admin | <pre> |
196 | 1 | Redmine Admin | git status |
197 | 1 | Redmine Admin | </pre> |
198 | 1 | Redmine Admin | |
199 | 1 | Redmine Admin | Il faut alors éditer le fichier concerné, résoudre le conflit à la main et faire un nouveau un @commit@ : |
200 | 1 | Redmine Admin | <pre> |
201 | 1 | Redmine Admin | git add [file.txt] |
202 | 1 | Redmine Admin | git commit -m"résolution du conflit" |
203 | 1 | Redmine Admin | </pre> |
204 | 1 | Redmine Admin | |
205 | 1 | Redmine Admin | * Pour repérer les fichiers qui n'ont pas été fusionné : |
206 | 1 | Redmine Admin | <pre> |
207 | 1 | Redmine Admin | git ls-files --unmerged |
208 | 1 | Redmine Admin | </pre> |
209 | 1 | Redmine Admin | |
210 | 1 | Redmine Admin | h1. Message de commit |
211 | 1 | Redmine Admin | |
212 | 1 | Redmine Admin | *IMPORTANT* : ne pas effectuer de modifications sur des commits déjà envoyés sur le serveur origin (le dépot). |
213 | 1 | Redmine Admin | |
214 | 1 | Redmine Admin | Avant d'envoyer vos données sur le serveur, il est possible de modifier/améliorer les messages de commit. |
215 | 1 | Redmine Admin | |
216 | 1 | Redmine Admin | h2. Modifier le dernier message de commit |
217 | 1 | Redmine Admin | |
218 | 1 | Redmine Admin | <pre> |
219 | 1 | Redmine Admin | git commit --amend |
220 | 1 | Redmine Admin | </pre> |
221 | 1 | Redmine Admin | Modifier, sauvegarder et quitter. |
222 | 1 | Redmine Admin | |
223 | 1 | Redmine Admin | h2. Modifier les trois derniers messages |
224 | 1 | Redmine Admin | |
225 | 1 | Redmine Admin | * On lance un rebase |
226 | 1 | Redmine Admin | <pre> |
227 | 1 | Redmine Admin | git rebase -i HEAD~3 |
228 | 1 | Redmine Admin | </pre> |
229 | 1 | Redmine Admin | * Un éditeur de texte s'ouvre avec quelque chose qui ressemble à ça: |
230 | 1 | Redmine Admin | <pre> |
231 | 1 | Redmine Admin | pick 6ffa65b update des bases de donnees editable=0 et pas 2 |
232 | 1 | Redmine Admin | pick 9697740 update des bases vers 2.2.3 : nettoyage et ajout d'un __init__.py (ref #11) |
233 | 1 | Redmine Admin | pick e56a7a4 Configuration des bases de donnees pour le passage en version 2.2.3 (fixes #11 : fixé) |
234 | 1 | Redmine Admin | |
235 | 1 | Redmine Admin | # Rebase cd9333c..e56a7a4 onto cd9333c |
236 | 1 | Redmine Admin | # |
237 | 1 | Redmine Admin | # Commands: |
238 | 1 | Redmine Admin | # p, pick = use commit |
239 | 1 | Redmine Admin | # r, reword = use commit, but edit the commit message |
240 | 1 | Redmine Admin | # e, edit = use commit, but stop for amending |
241 | 1 | Redmine Admin | # s, squash = use commit, but meld into previous commit |
242 | 1 | Redmine Admin | # |
243 | 1 | Redmine Admin | # If you remove a line here THAT COMMIT WILL BE LOST. |
244 | 1 | Redmine Admin | # However, if you remove everything, the rebase will be aborted. |
245 | 1 | Redmine Admin | # |
246 | 1 | Redmine Admin | </pre> |
247 | 1 | Redmine Admin | * Changer pick en edit sur les lignes correspondantes aux commit à modifier, par exemple : |
248 | 1 | Redmine Admin | <pre> |
249 | 1 | Redmine Admin | edit 6ffa65b update des bases de donnees editable=0 et pas 2 |
250 | 1 | Redmine Admin | pick 9697740 update des bases vers 2.2.3 : nettoyage et ajout d'un __init__.py (ref #11) |
251 | 1 | Redmine Admin | pick e56a7a4 Configuration des bases de donnees pour le passage en version 2.2.3 (fixes #11 : fixé) |
252 | 1 | Redmine Admin | </pre> |
253 | 1 | Redmine Admin | * Sauver et quitter. |
254 | 1 | Redmine Admin | * Lancer la commande : |
255 | 1 | Redmine Admin | <pre> |
256 | 1 | Redmine Admin | git commit --amend |
257 | 1 | Redmine Admin | </pre> |
258 | 1 | Redmine Admin | * Modifier les messages de commit, par ex : |
259 | 1 | Redmine Admin | <pre> |
260 | 1 | Redmine Admin | update des bases de donnees editable=0 et pas 2 (ref #11) |
261 | 1 | Redmine Admin | </pre> |
262 | 1 | Redmine Admin | * Sauvegarder et quitter |
263 | 1 | Redmine Admin | * Lancer la commande : |
264 | 1 | Redmine Admin | <pre> |
265 | 1 | Redmine Admin | git rebase --continue |
266 | 1 | Redmine Admin | </pre> |
267 | 1 | Redmine Admin | * Vérifier les messages de commit |
268 | 1 | Redmine Admin | <pre> |
269 | 1 | Redmine Admin | git log |
270 | 1 | Redmine Admin | </pre> |
271 | 1 | Redmine Admin | |
272 | 1 | Redmine Admin | |
273 | 1 | Redmine Admin | h2. Fusionner des commits |
274 | 1 | Redmine Admin | |
275 | 1 | Redmine Admin | Il est possible de fusionner des commit afin d'éviter des commits multiples pour des modifications mineures. |
276 | 1 | Redmine Admin | * Lancer un git rebase |
277 | 1 | Redmine Admin | <pre> |
278 | 1 | Redmine Admin | git rebase -i HEAD~3 |
279 | 1 | Redmine Admin | </pre> |
280 | 1 | Redmine Admin | <pre> |
281 | 1 | Redmine Admin | pick 16098ec Ajout d'icône gepi et cdt (ref #51) |
282 | 1 | Redmine Admin | pick f244e89 Deplacement d'icone |
283 | 1 | Redmine Admin | pick 7c8670c Deplacement des icones sources |
284 | 1 | Redmine Admin | |
285 | 1 | Redmine Admin | # Rebase 5f5bfee..7c8670c onto 5f5bfee |
286 | 1 | Redmine Admin | # |
287 | 1 | Redmine Admin | # Commands: |
288 | 1 | Redmine Admin | # p, pick = use commit |
289 | 1 | Redmine Admin | # r, reword = use commit, but edit the commit message |
290 | 1 | Redmine Admin | # e, edit = use commit, but stop for amending |
291 | 1 | Redmine Admin | # s, squash = use commit, but meld into previous commit |
292 | 1 | Redmine Admin | # |
293 | 1 | Redmine Admin | # If you remove a line here THAT COMMIT WILL BE LOST. |
294 | 1 | Redmine Admin | # However, if you remove everything, the rebase will be aborted. |
295 | 1 | Redmine Admin | # |
296 | 1 | Redmine Admin | </pre> |
297 | 1 | Redmine Admin | |
298 | 1 | Redmine Admin | * Changer pick en squash fusionne votre commit avec la ligne au-dessus |
299 | 1 | Redmine Admin | <pre> |
300 | 1 | Redmine Admin | pick 16098ec Ajout d'icône gepi et cdt (ref #51) |
301 | 1 | Redmine Admin | squash f244e89 Deplacement d'icone |
302 | 1 | Redmine Admin | squash 7c8670c Deplacement des icones sources |
303 | 1 | Redmine Admin | </pre> |
304 | 1 | Redmine Admin | * Sauver et quitter, Un éditeur s'ouvre: |
305 | 1 | Redmine Admin | <pre> |
306 | 1 | Redmine Admin | # This is a combination of 3 commits. |
307 | 1 | Redmine Admin | # The first commit's message is: |
308 | 1 | Redmine Admin | Ajout d'icône gepi et cdt (ref #51) |
309 | 1 | Redmine Admin | |
310 | 1 | Redmine Admin | # This is the 2nd commit message: |
311 | 1 | Redmine Admin | |
312 | 1 | Redmine Admin | Deplacement d'icone |
313 | 1 | Redmine Admin | |
314 | 1 | Redmine Admin | # This is the 3rd commit message: |
315 | 1 | Redmine Admin | |
316 | 1 | Redmine Admin | Deplacement des icones sources |
317 | 1 | Redmine Admin | |
318 | 1 | Redmine Admin | # Please enter the commit message for your changes. Lines starting |
319 | 1 | Redmine Admin | # with '#' will be ignored, and an empty message aborts the commit. |
320 | 1 | Redmine Admin | # Not currently on any branch. |
321 | 1 | Redmine Admin | # Changes to be committed: |
322 | 1 | Redmine Admin | # (use "git reset HEAD <file>..." to unstage) |
323 | 1 | Redmine Admin | # |
324 | 1 | Redmine Admin | # modified: eole/tmpls/update_creole_posh.sql |
325 | 1 | Redmine Admin | # renamed: plugins/plugin_desktop/icones/old/Corbeille.png -> plugins/plugin_desktop/icones/Corbeille.png |
326 | 1 | Redmine Admin | # renamed: plugins/plugin_desktop/icones/old/Courrier.png -> plugins/plugin_desktop/icones/Courrier.png |
327 | 1 | Redmine Admin | # renamed: plugins/plugin_desktop/icones/old/agenda.png -> plugins/plugin_desktop/icones/agenda.png |
328 | 1 | Redmine Admin | # new file: plugins/plugin_desktop/icones/cdt.png |
329 | 1 | Redmine Admin | # modified: plugins/plugin_desktop/icones/dir.png |
330 | 1 | Redmine Admin | # modified: plugins/plugin_desktop/icones/gepi.png |
331 | 1 | Redmine Admin | # renamed: plugins/plugin_desktop/icones/old/mail.jpg -> plugins/plugin_desktop/icones/mail.jpg |
332 | 1 | Redmine Admin | # modified: plugins/plugin_desktop/icones/mail.png |
333 | 1 | Redmine Admin | # new file: sources-desktop/icones/cdt.xcf |
334 | 1 | Redmine Admin | # renamed: plugins/plugin_desktop/icones/grand/moodle.gif -> sources-desktop/icones/moodle.gif |
335 | 1 | Redmine Admin | # |
336 | 1 | Redmine Admin | # Untracked files: |
337 | 1 | Redmine Admin | # (use "git add <file>..." to include in what will be committed) |
338 | 1 | Redmine Admin | # |
339 | 1 | Redmine Admin | # databases/bdd/scribe-posh.sql.sav |
340 | 1 | Redmine Admin | </pre> |
341 | 1 | Redmine Admin | * Éditer les messages (un message suffit) |
342 | 1 | Redmine Admin | <pre> |
343 | 1 | Redmine Admin | # The first commit's message is: |
344 | 1 | Redmine Admin | Ajout d'icône pour les applications scribe (ref #51) |
345 | 1 | Redmine Admin | # This is the 2nd commit message: |
346 | 1 | Redmine Admin | |
347 | 1 | Redmine Admin | # This is the 3rd commit message: |
348 | 1 | Redmine Admin | |
349 | 1 | Redmine Admin | # Please enter the commit message for your changes. Lines starting |
350 | 1 | Redmine Admin | </pre> |
351 | 1 | Redmine Admin | * Sauver et quitter |
352 | 1 | Redmine Admin | * Vérifier que cela ressemble bien à ce que vous voulez |
353 | 1 | Redmine Admin | <pre> |
354 | 1 | Redmine Admin | git log |
355 | 1 | Redmine Admin | </pre> |
356 | 1 | Redmine Admin | |
357 | 1 | Redmine Admin | |
358 | 1 | Redmine Admin | h1. Trucs et astuces |
359 | 1 | Redmine Admin | |
360 | 1 | Redmine Admin | * Résoudre un signalement avec l'ajout de "fixes #<numéro du signalement>" |
361 | 1 | Redmine Admin | <pre> |
362 | 1 | Redmine Admin | git commit -m"La nouvelle feature fixes #<numéro du signalement>" |
363 | 1 | Redmine Admin | git http-push .... |
364 | 1 | Redmine Admin | </pre> |
365 | 1 | Redmine Admin | |
366 | 1 | Redmine Admin | * Faire référence à un signalement |
367 | 1 | Redmine Admin | <pre> |
368 | 1 | Redmine Admin | git commit -m"bla bla bal du bug #<numéro du signalement>" |
369 | 1 | Redmine Admin | </pre> |
370 | 1 | Redmine Admin | |
371 | 1 | Redmine Admin | * Activer la coloration syntaxique |
372 | 1 | Redmine Admin | <pre> |
373 | 1 | Redmine Admin | git config --global color.ui true |
374 | 1 | Redmine Admin | </pre> |
375 | 1 | Redmine Admin | |
376 | 1 | Redmine Admin | * Pour controler les fichiers à ne JAMAIS prendre en compte (@commit@), utiliser le fichier @~/.gitignore@. Exemple d'un fichier @~/.gitignore@ : |
377 | 1 | Redmine Admin | <pre> |
378 | 1 | Redmine Admin | # ignorer le fichier lui même |
379 | 1 | Redmine Admin | .gitignore |
380 | 1 | Redmine Admin | # les fichiers de sauvegarde VIM |
381 | 1 | Redmine Admin | *~ |
382 | 1 | Redmine Admin | # ignorer les fichiers html générés |
383 | 1 | Redmine Admin | *.html |
384 | 1 | Redmine Admin | # sauf mon_fichier.html que je veux prendre en compte |
385 | 1 | Redmine Admin | !mon_fichier.html |
386 | 1 | Redmine Admin | # ignorer les dossiers @.svn@ |
387 | 1 | Redmine Admin | .svn |
388 | 1 | Redmine Admin | # ignore documentation buid html files |
389 | 1 | Redmine Admin | .build |
390 | 1 | Redmine Admin | </pre> |
391 | 1 | Redmine Admin | |
392 | 1 | Redmine Admin | * Le fichier @~/.gitconfig@ peut permettre d'éviter de taper trop au clavier : |
393 | 1 | Redmine Admin | <pre> |
394 | 1 | Redmine Admin | [alias] |
395 | 1 | Redmine Admin | st = status |
396 | 1 | Redmine Admin | di = diff |
397 | 1 | Redmine Admin | co = checkout |
398 | 1 | Redmine Admin | ci = commit |
399 | 1 | Redmine Admin | br = branch |
400 | 1 | Redmine Admin | sta = stash |
401 | 1 | Redmine Admin | </pre> |
402 | 1 | Redmine Admin | |
403 | 1 | Redmine Admin | * Pour éviter de taper l'URL et son mot de passe à chaque @push@ et @pull@, il faut : |
404 | 1 | Redmine Admin | |
405 | 1 | Redmine Admin | * configurer l'URL du projet |
406 | 1 | Redmine Admin | <pre> |
407 | 1 | Redmine Admin | git config remote.origin.url http://194.167.18.22/git/projet/ |
408 | 1 | Redmine Admin | git config remote.origin.mirror false |
409 | 1 | Redmine Admin | </pre> |
410 | 1 | Redmine Admin | * renseigner le fichier @~/.netrc@ : |
411 | 1 | Redmine Admin | <pre> |
412 | 2 | samuel morin | machine dev-eole.ac-dijon.fr |
413 | 1 | Redmine Admin | login monlogin |
414 | 1 | Redmine Admin | password monmotdepasse |
415 | 1 | Redmine Admin | </pre> |
416 | 1 | Redmine Admin | * paramétrer les droits du fichier @~/.netrc@ : |
417 | 1 | Redmine Admin | <pre> |
418 | 1 | Redmine Admin | chmod 600 ~/.netrc |
419 | 1 | Redmine Admin | </pre> |
420 | 1 | Redmine Admin | Ensuite @git push@ et @git pull@ ne posent plus de questions. |
421 | 1 | Redmine Admin | |
422 | 1 | Redmine Admin | |
423 | 1 | Redmine Admin | * Pour faire le ménage : |
424 | 1 | Redmine Admin | <pre> |
425 | 1 | Redmine Admin | git repack |
426 | 1 | Redmine Admin | git prune |
427 | 1 | Redmine Admin | </pre> |
428 | 1 | Redmine Admin | |
429 | 1 | Redmine Admin | * Pour repérer des @commit@ dans des branches qui n'ont pas été fusionnés (@merge@) dans la branche principale : |
430 | 1 | Redmine Admin | * Pour voir les @commit@ dans la branche *ma_branche* qui n'ont pas été fusionnés (@merge@) dans *master* : |
431 | 1 | Redmine Admin | <pre> |
432 | 1 | Redmine Admin | git cherry -v master ma_branche |
433 | 1 | Redmine Admin | </pre> |
434 | 1 | Redmine Admin | |
435 | 1 | Redmine Admin | h1. De subversion vers git |
436 | 1 | Redmine Admin | |
437 | 1 | Redmine Admin | Il n'existe pas de commande *@update@*. Lorsqu'un fichier a été modifié localement par erreur et qu'on veut récupérer l'original, les habitudes étaient : |
438 | 1 | Redmine Admin | <pre> |
439 | 1 | Redmine Admin | rm mon_fichier |
440 | 1 | Redmine Admin | svn update |
441 | 1 | Redmine Admin | </pre> |
442 | 1 | Redmine Admin | |
443 | 1 | Redmine Admin | A la place, il faut faire |
444 | 1 | Redmine Admin | <pre> |
445 | 1 | Redmine Admin | git checkout mon_fichier |
446 | 1 | Redmine Admin | </pre> |
447 | 1 | Redmine Admin | |
448 | 1 | Redmine Admin | Pour revenir à un checkout frais dans le projet entier, utiliser *@reset@*. On peut annuler un commit en faisant : |
449 | 1 | Redmine Admin | |
450 | 1 | Redmine Admin | <pre> |
451 | 1 | Redmine Admin | git reset --hard HEAD |
452 | 1 | Redmine Admin | </pre> |
453 | 1 | Redmine Admin | |
454 | 1 | Redmine Admin | h1. Créer un patch et l'intégrer |
455 | 1 | Redmine Admin | |
456 | 1 | Redmine Admin | Dans un projet (Ex.: conf-horus) on a créé une branche "ma_branche" dans laquelle on a fait des modifications (par rapport à "master"). |
457 | 1 | Redmine Admin | |
458 | 1 | Redmine Admin | On veut récupérer un fichier recensant les différences entre la branche *master* et la branche *ma_branche* (un fichier @diff@) : |
459 | 1 | Redmine Admin | <pre> |
460 | 1 | Redmine Admin | git diff master [nom-de-branche] > file.patch |
461 | 1 | Redmine Admin | </pre> |
462 | 1 | Redmine Admin | |
463 | 1 | Redmine Admin | * Une fois le patch récupéré, pour l'inclure dans la branche *master* : |
464 | 1 | Redmine Admin | |
465 | 1 | Redmine Admin | <pre> |
466 | 1 | Redmine Admin | git apply --stat file.patch |
467 | 1 | Redmine Admin | git apply --check file.patch |
468 | 1 | Redmine Admin | <pre> permet de tester le patch, et : |
469 | 1 | Redmine Admin | <pre> |
470 | 1 | Redmine Admin | git apply file.patch |
471 | 1 | Redmine Admin | </pre> permet de l'appliquer |
472 | 9 | Gaston TJEBBES | |
473 | 9 | Gaston TJEBBES | h1. Tags |
474 | 9 | Gaston TJEBBES | |
475 | 9 | Gaston TJEBBES | |
476 | 9 | Gaston TJEBBES | *git* fait une différence entre les branches et les tags, cela se voit bien avec *git-gui* (vue de l'historique des branches). |
477 | 9 | Gaston TJEBBES | |
478 | 9 | Gaston TJEBBES | Une branche est modifiable, un tag ne l'est pas. |
479 | 9 | Gaston TJEBBES | |
480 | 9 | Gaston TJEBBES | * Création du @tag@ : |
481 | 9 | Gaston TJEBBES | <pre> |
482 | 9 | Gaston TJEBBES | git tag mon-premier-tag |
483 | 9 | Gaston TJEBBES | </pre> |
484 | 9 | Gaston TJEBBES | |
485 | 9 | Gaston TJEBBES | * Liste des tags : |
486 | 9 | Gaston TJEBBES | <pre> |
487 | 9 | Gaston TJEBBES | git tag |
488 | 9 | Gaston TJEBBES | </pre> |
489 | 9 | Gaston TJEBBES | |
490 | 9 | Gaston TJEBBES | * Commit d'un @tag@ : |
491 | 9 | Gaston TJEBBES | <pre> |
492 | 9 | Gaston TJEBBES | git push --tags http://login@dev-eole.ac-dijon.fr/git/sandbox |
493 | 9 | Gaston TJEBBES | </pre> |
494 | 9 | Gaston TJEBBES | |
495 | 9 | Gaston TJEBBES | * ou bien : |
496 | 9 | Gaston TJEBBES | <pre> |
497 | 9 | Gaston TJEBBES | git push http://login@dev-eole.ac-dijon.fr/git/sandbox <nom_tag> |
498 | 9 | Gaston TJEBBES | </pre> |
499 | 9 | Gaston TJEBBES | |
500 | 9 | Gaston TJEBBES | * ou encore : |
501 | 9 | Gaston TJEBBES | <pre> |
502 | 9 | Gaston TJEBBES | git push http://login@dev-eole.ac-dijon.fr/git/sandbox <nom_branche> <nom_tag> |
503 | 9 | Gaston TJEBBES | </pre> |
504 | 9 | Gaston TJEBBES | |
505 | 9 | Gaston TJEBBES | * Recupérer un @tag@ : |
506 | 9 | Gaston TJEBBES | <pre> |
507 | 9 | Gaston TJEBBES | git checkout tags/<nom_tag> |
508 | 9 | Gaston TJEBBES | </pre> |
509 | 9 | Gaston TJEBBES | |
510 | 9 | Gaston TJEBBES | * Pour voir quel @commit@ exactement a été taggé : |
511 | 9 | Gaston TJEBBES | <pre> |
512 | 9 | Gaston TJEBBES | git show <nom_tag> |
513 | 9 | Gaston TJEBBES | </pre> |