diff --git a/git_tutorial.md b/git_tutorial.md index 08ac74e4332df4fc6b7d816e84633117d5f0c7cb..1f884a69fbb41630a7c2b0a5b8b6ac4392760391 100644 --- a/git_tutorial.md +++ b/git_tutorial.md @@ -1,4 +1,6 @@ % Introduction à Git +% Orestis Malaspinas +% Version # Des références @@ -194,11 +196,105 @@ Date: Sun Mar 4 22:25:24 2018 +0100 mon premier commit ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -# Revenir en arrière dans l'historique (1/3) +# Revenir en arrière dans l'historique (1/5) ## Commandes: `git checkout`, `git reset` -1. Faire une modification dans un fichier qu'on aurait pas dû faire. +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. +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.bash .numberLines} +[tutorial]$ echo Oh no! An awful modification! > premierfichier.c +[tutorial]$ git status +On branch master +Your branch is up to date with 'origin/master'. + +Changes not staged for commit: + (use "git add <file>..." to update what will be committed) + (use "git checkout -- <file>..." to discard changes in working directory) + + modified: premierfichier.c + +no changes added to commit (use "git add" and/or "git commit -a") +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# Revenir en arrière dans l'historique (2/5) + +## Commandes: `git checkout`, `git reset` + +### Une modification dans un fichier qu'on aurait pas voulu faire. + +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.bash .numberLines} +[tutorial]$ git checkout premierfichier.c +[tutorial]$ git status +On branch master +Your branch is up to date with 'origin/master'. + +nothing to commit, working tree clean + +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# Revenir en arrière dans l'historique (3/5) + +## Commandes: `git checkout`, `git reset` + +### Faire un `git add` qu'on aurait pas dû faire. + +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.bash .numberLines} +[tutorial]$ echo Oh no! An awful modification! > premierfichier.c +[tutorial]$ git add premierfichier.c +[tutorial]$ git status +On branch master +Your branch is up to date with 'origin/master'. + +Changes to be committed: + (use "git reset HEAD <file>..." to unstage) + + modified: premierfichier.c +[tutorial]$ git reset HEAD +Unstaged changes after reset: +M premierfichier.c +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# Revenir en arrière dans l'historique (4/5) + +## Commandes: `git checkout`, `git reset` + +### Faire un `git add` qu'on aurait pas dû faire. + +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.bash .numberLines} +[tutorial]$ git status +On branch master +Your branch is up to date with 'origin/master'. + +Changes not staged for commit: + (use "git add <file>..." to update what will be committed) + (use "git checkout -- <file>..." to discard changes in working directory) + + modified: premierfichier.c + +no changes added to commit (use "git add" and/or "git commit -a") +[tutorial]$ git diff +diff --git a/premierfichier.c b/premierfichier.c +index 9622e40..cfd5469 100644 +--- a/premierfichier.c ++++ b/premierfichier.c +@@ -1 +1 @@ +-Wild World ++Oh no! An awful modification! +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# Revenir en arrière dans l'historique (4/5) + +## Commandes: `git checkout`, `git reset` + +### Faire un `git commit` qu'on aurait pas dû faire. + +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.bash .numberLines} +[tutorial]$ git commit -am "troisieme commit" +[master 0563c02] troisieme commit + 1 file changed, 1 insertion(+), 1 deletion(-) +[tutorial]$ git reset f9ab3ec4a00c46a12d7a45f133295acc5fb5cd20 +[tutorial]$ git checkout premierfichier.c +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~