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