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