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