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