From 8de7177932c1eb29e7ad1bafa2cc8970ea4ed9af Mon Sep 17 00:00:00 2001
From: Orestis <orestis.malaspinas@pm.me>
Date: Sun, 7 Nov 2021 23:10:41 +0100
Subject: [PATCH] updated slides with gitignore in base tutorial

---
 git_tutorial.md           | 81 +++++++++++++++++++++++++++++++--------
 git_tutorial_gitignore.md |  2 +-
 2 files changed, 66 insertions(+), 17 deletions(-)

diff --git a/git_tutorial.md b/git_tutorial.md
index 2dd5411..020eba4 100644
--- a/git_tutorial.md
+++ b/git_tutorial.md
@@ -1,6 +1,6 @@
 % Introduction à Git
 % Orestis Malaspinas
-% commit ee7a89cab009aba5b291125eb0b28a4bd7034fc9
+% commit e5c2d675e68c4df94a9d3b0df48f8feb5ec9c1ab
 
 # Des références
 
@@ -55,7 +55,7 @@ Typiquement un projet git possède un serveur "officiel" géré par l'administra
 
 # Principe de fonctionnement de Git (3/3)
 
-![Avec un serveur central complète](figs/comm_normal.svg){width="80%"}
+![Avec un serveur central](figs/comm_normal.svg){width="80%"}
 
 # Exemple de fonctionnement
 
@@ -358,6 +358,15 @@ Automatic merge failed; fix conflicts and then commit the result.
 
 ### Il ne reste qu'à corriger le conflit et refaire un `git commit`, `git push`
 
+# Un `git push` par erreur
+
+* Un `git push` est très difficile à "effacer".
+* Cela revient à *réécrire* l'historique de votre projet.
+    * Cela est *dangereux*, surtout quand on travail à plusieurs.
+* Le plus simple est de revenir à une version antérieure et faire un nouveau
+  commit.
+* Il existe des techniques *violentes* qu'on verra pas ici.
+
 # Retirer un fichier du contrôle de version (1/3)
 
 ## Commande: `git rm`
@@ -366,9 +375,9 @@ Automatic merge failed; fix conflicts and then commit the result.
 - **Attention : le fichier ne disparaît pas de l'historique.**
 
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.bash}
-[malaspor@perka tutorial]$ git rm premierfichier.c
+[orestis@perka tutorial]$ git rm premierfichier.c
 rm 'premierfichier.c'
-[malaspor@perka tutorial]$ git status
+[orestis@perka tutorial]$ git status
 On branch master
 Your branch is up to date with 'origin/master'.
 
@@ -376,7 +385,7 @@ Changes to be committed:
   (use "git reset HEAD <file>..." to unstage)
 
 	deleted:    premierfichier.c
-[malaspor@perka tutorial]$ git commit -am "efface donc ce fichier"
+[orestis@perka tutorial]$ git commit -am "efface donc ce fichier"
 [master 8f76d90] efface donc ce fichier
  1 file changed, 1 deletion(-)
  delete mode 100644 premierfichier.c
@@ -387,12 +396,12 @@ Changes to be committed:
 ## Commande: `git rm` (1/2)
 
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.bash}
-[malaspor@perka tutorial]$ ls -ltr
+[orestis@perka tutorial]$ ls -ltr
 total 0
-[malaspor@perka tutorial]$ git reset bbb151324289dc2f85468f5721ec1021692dd216
+[orestis@perka tutorial]$ git reset bbb151324289dc2f85468f5721ec1021692dd216
 Unstaged changes after reset:
 D	premierfichier.c
-[malaspor@perka tutorial]$ git status
+[orestis@perka tutorial]$ git status
 On branch master
 Your branch is up to date with 'origin/master'.
 
@@ -412,26 +421,66 @@ no changes added to commit (use "git add" and/or "git commit -a")
 On peut retrouver le fichier dans l'historique.
 
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.bash}
-[malaspor@perka tutorial]$ ls -ltr
+[orestis@perka tutorial]$ ls -ltr
 total 0
-[malaspor@perka tutorial]$ git checkout premierfichier.c
-[malaspor@perka tutorial]$ ls -ltr
+[orestis@perka tutorial]$ git checkout premierfichier.c
+[orestis@perka tutorial]$ ls -ltr
 total 4
--rw-r--r-- 1 malaspor malaspor 17  5 mar 11:13 premierfichier.c
+-rw-r--r-- 1 orestis orestis 17  5 mar 11:13 premierfichier.c
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 # Commandes  et concept un peu plus avancés
 
 Il existe une **grande quantité** de fonctionnalités non discutées ici:
 
-1. `.gitignore`
-2. `git branch`
-3. `git merge`
-4. `git tag`
+1. `git branch`
+2. `git merge`
+3. `git tag`
+4. `git rebase`
 
 **ET SURTOUT:**
 
 5. `git trois-lignes-de-commandes-incompréhensibles-que-seul stackoverflow-peut-vous-permettre-d'écrire`
 
+# Le fichier `.gitignore`
+
+## L'état des fichiers
+
+Git voit les fichiers dans trois états possibles:
+
+1. *tracked*, un fichier qui a été `add` (`staged`) ou `commit` (dans la terminologie git).
+2. *untracked*, un fichier qui n'a pas été `add` ou `commit`.
+3. *ignored*, un fichier qui est explicitement ignoré par git.
+
+## Quels fichiers ignorer
+
+On ignore typiquement:
+
+* Les fichiers binaires: exécutables, images, ...
+* Les produits de compilation: `*.o`, `*.pyc`, ...
+* Les produits d'exécutions: logs, ...
+* Les fichiers de configuration d'un IDE: .vscode, ...
+* Les fichiers système.
+
+## Comment ignorer des fichiers?
+
+* Créer un fichier texte nommé `.gitignore`.
+* L'ajouter au répo git et le "commit".
+* Y ajouter les règles à suivre pour ignorer les fichiers.
+
+Exemple: [^1]
+
+```bash
+biden      # ignore le fichier biden
+*.o        # ignore tous les fichier `.o`
+!trump.o   # mais PAS trump.o
+sanders    # ignore le répertoire sanders
+**/sanders # ignore tous les répertoires sanders
+```
+
+[^1]: Pour une liste plus exhaustive voir le site <https://bit.ly/2HTZJyQ> par exemple.
+
+## Bibliographie
 
+Ces quelques slides sont inspirés du site <https://bit.ly/2HTZJyQ>.
 
diff --git a/git_tutorial_gitignore.md b/git_tutorial_gitignore.md
index 35542e6..de62f3e 100644
--- a/git_tutorial_gitignore.md
+++ b/git_tutorial_gitignore.md
@@ -1,6 +1,6 @@
 % Introduction à Git partie 2
 % Orestis Malaspinas
-% commit ee7a89cab009aba5b291125eb0b28a4bd7034fc9
+% commit e5c2d675e68c4df94a9d3b0df48f8feb5ec9c1ab
 
 # Le fichier `.gitignore`
 
-- 
GitLab