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