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