From 19171d146b2049d71ffd6c515e3010eece01d00d Mon Sep 17 00:00:00 2001 From: Orestis Malaspinas <orestis.malaspinas@hesge.ch> Date: Mon, 11 Mar 2019 11:37:38 +0100 Subject: [PATCH] =?UTF-8?q?mises=20=C3=A0=20jour=20et=20corrections=20typo?= =?UTF-8?q?s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- git_tutorial.md | 75 +++++++++++++++++++++++++------------------------ 1 file changed, 39 insertions(+), 36 deletions(-) diff --git a/git_tutorial.md b/git_tutorial.md index 129d85d..bd796cd 100644 --- a/git_tutorial.md +++ b/git_tutorial.md @@ -1,6 +1,6 @@ % Introduction à Git % Orestis Malaspinas -% Version 6a487a9ed53c19b24e7b3dc0cff9a38896ccf666 +% # Des références @@ -12,7 +12,7 @@ Il existe énormément de très bons documents et tutoriels en ligne: Des tas de repo en ligne: - [Githepia](https://githepia.hesge.ch) -- [Githhub](https://www.github.com) +- [Github](https://www.github.com) - [Gitlab](https://www.gitlab.com) Et des GUI assez utiles: @@ -25,10 +25,10 @@ Et des GUI assez utiles: - Git est un outil de gestion de versions (dév. par L. Torvalds). * Cela évite d'avoir à gérer les fichiers d'un projet comme: - fichier.c - - fichier_10_3_2018.c - - fichier_10_3_2018_16h.c - - fichier_10_3_2018_16h_Malaspinas.c - - fichier_10_3_2018_16h_Gluck.c + - fichier_10_3_2019.c + - fichier_10_3_2019_16h.c + - fichier_10_3_2019_16h_Malaspinas.c + - fichier_10_3_2019_16h_Antoniadis.c * L'historique est accessible à tout moment. * Difficile d'écraser le mauvais fichier lors d'une synchronisation. - Possibilité de découpler le développement dans un projet. @@ -55,7 +55,7 @@ Typiquement un projet git possède un serveur "officiel" géré par l'administra 1. Création d'un dépôt *tutorial* git sur [https://githepia.hesge.ch](https://githepia.hesge.ch). 2. Clone du dépôt. -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.bash .numberLines} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.bash} $ git clone ssh://git@ssh.hesge.ch:10572/orestis.malaspin/tutorial.git Cloning into 'tutorial'... warning: You appear to have cloned an empty repository. @@ -73,7 +73,7 @@ $ cd tutorial 2. Ajout du `premierfichier.c` aux fichiers suivis par git. 3. *Commit* du fichier ajouté à l'historique des modifications. 4. *Push* de l'état de l'historique sur le serveur. -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.bash .numberLines} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.bash} [tutorial]$ echo Hello World > premierfichier.c [tutorial]$ git status On branch master @@ -93,7 +93,7 @@ nothing added to commit but untracked files present (use "git add" to track) ## Commandes: `git add`, `git status`, `git commit`, `git push` -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.bash .numberLines} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.bash} [tutorial]$ git add premierfichier.c [tutorial]$ git status On branch master @@ -115,7 +115,7 @@ Changes to be committed: ## Commandes: `git add`, `git status`, `git commit`, `git push` -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.bash .numberLines} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.bash} [tutorial]$ git status On branch master Your branch is based on 'origin/master', but the upstream is gone. @@ -138,7 +138,7 @@ To ssh://ssh.hesge.ch:10572/orestis.malaspin/tutorial.git 1. Modification du fichier `premierfichier.c`. 2. Ajout/commit/push des modifictations. -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.bash .numberLines} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.bash} [tutorial]$ echo Wild World > premierfichier.c [tutorial]$ git status On branch master @@ -157,7 +157,7 @@ no changes added to commit (use "git add" and/or "git commit -a") ## Commandes: `git diff`, `git log` -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.bash .numberLines} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.bash} [tutorial]$ git diff diff --git a/premierfichier.c b/premierfichier.c index 557db03..9622e40 100644 @@ -181,7 +181,7 @@ To ssh://ssh.hesge.ch:10572/orestis.malaspin/tutorial.git ## Commandes: `git diff`, `git log` -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.bash .numberLines} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.bash} [tutorial]$ git log commit f9ab3ec4a00c46a12d7a45f133295acc5fb5cd20 (HEAD -> master, origin/master) Author: Orestis Malaspinas <orestis.malaspinas@hesge.ch> @@ -200,11 +200,11 @@ Date: Sun Mar 4 22:25:24 2018 +0100 ## Commandes: `git checkout`, `git reset` -1. Faire une modification dans un fichier qu'on aurait pas voulu faire. -2. Faire un `git add` qu'on aurait pas dû faire. -3. Faire un `git commit` qu'on aurait pas dû faire. +1. Faire une modification dans un fichier par erreur. +2. Faire un `git add` par erreur. +3. Faire un `git commit` par erreur. -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.bash .numberLines} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.bash} [tutorial]$ echo Oh no! An awful modification! > premierfichier.c [tutorial]$ git status On branch master @@ -223,10 +223,10 @@ no changes added to commit (use "git add" and/or "git commit -a") ## Commandes: `git checkout`, `git reset` -### Une modification dans un fichier qu'on aurait pas voulu faire. +### Une modification dans un fichier par erreur -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.bash .numberLines} -[tutorial]$ git checkout premierfichier.c +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.bash} +[tutorial]$ git checkout premierfichier.c [tutorial]$ git status On branch master Your branch is up to date with 'origin/master'. @@ -239,9 +239,9 @@ nothing to commit, working tree clean ## Commandes: `git checkout`, `git reset` -### Faire un `git add` qu'on aurait pas dû faire. +### Faire un `git add` par erreur (1/2) -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.bash .numberLines} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.bash} [tutorial]$ echo Oh no! An awful modification! > premierfichier.c [tutorial]$ git add premierfichier.c [tutorial]$ git status @@ -261,9 +261,9 @@ M premierfichier.c ## Commandes: `git checkout`, `git reset` -### Faire un `git add` qu'on aurait pas dû faire. +### Faire un `git add` par erreur (2/2) -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.bash .numberLines} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.bash} [tutorial]$ git status On branch master Your branch is up to date with 'origin/master'. @@ -289,9 +289,9 @@ index 9622e40..cfd5469 100644 ## Commandes: `git checkout`, `git reset` -### Faire un `git commit` qu'on aurait pas dû faire. +### Faire un `git commit` par erreur (1/2) -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.bash .numberLines} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.bash} [tutorial]$ git commit -am "troisieme commit" [master 0563c02] troisieme commit 1 file changed, 1 insertion(+), 1 deletion(-) @@ -313,9 +313,9 @@ no changes added to commit ## Commandes: `git checkout`, `git reset` -### Faire un `git commit` qu'on aurait pas dû faire. +### Faire un `git commit` par erreur (2/2) -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.bash .numberLines} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.bash} [tutorial]$ echo Wonderful World > premierfichier.c [tutorial]$ git commit -am "la bonne troisieme modification" [master 1b42970] la bonne troisieme modification @@ -338,12 +338,12 @@ Automatic merge failed; fix conflicts and then commit the result. # Retirer un fichier du contrôle de version (1/3) ## Commande: `git rm` - + - Il n'est plus nécessaire de suivre un fichier. -- **Attention**: le fichier ne disparaît pas de l'historique. +- **Attention : le fichier ne disparaît pas de l'historique.** -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.bash .numberLines} -[malaspor@perka tutorial]$ git rm premierfichier.c +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.bash} +[malaspor@perka tutorial]$ git rm premierfichier.c rm 'premierfichier.c' [malaspor@perka tutorial]$ git status On branch master @@ -361,9 +361,9 @@ Changes to be committed: # Retirer un fichier du contrôle de version (2/3) -## Commande: `git rm` +## Commande: `git rm` (1/2) -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.bash .numberLines} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.bash} [malaspor@perka tutorial]$ ls -ltr total 0 [malaspor@perka tutorial]$ git reset bbb151324289dc2f85468f5721ec1021692dd216 @@ -384,11 +384,11 @@ no changes added to commit (use "git add" and/or "git commit -a") # Retirer un fichier du contrôle de version (3/3) -## Commande: `git rm` +## Commande: `git rm` (2/2) On peut retrouver le fichier dans l'historique. -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.bash .numberLines} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.bash} [malaspor@perka tutorial]$ ls -ltr total 0 [malaspor@perka tutorial]$ git checkout premierfichier.c @@ -405,6 +405,9 @@ Il existe une **grande quantité** de fonctionnalités non discutées ici: 2. `git branch` 3. `git merge` 4. `git tag` + +**ET SURTOUT:** + 5. `git trois-lignes-de-commandes-incompréhensibles-que-seul stackoverflow-peut-vous-permettre-d'écrire` -- GitLab