diff --git a/git_tutorial.md b/git_tutorial.md index d0ed29ccbb2dd65fe956572d00763d880e88cb76..fb393166cc30fd3f36d571c7682044c34f01914d 100644 --- a/git_tutorial.md +++ b/git_tutorial.md @@ -196,7 +196,7 @@ Date: Sun Mar 4 22:25:24 2018 +0100 mon premier commit ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -# Revenir en arrière dans l'historique (1/5) +# Revenir en arrière dans l'historique (1/6) ## Commandes: `git checkout`, `git reset` @@ -219,7 +219,7 @@ Changes not staged for commit: no changes added to commit (use "git add" and/or "git commit -a") ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -# Revenir en arrière dans l'historique (2/5) +# Revenir en arrière dans l'historique (2/6) ## Commandes: `git checkout`, `git reset` @@ -235,7 +235,7 @@ nothing to commit, working tree clean ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -# Revenir en arrière dans l'historique (3/5) +# Revenir en arrière dans l'historique (3/6) ## Commandes: `git checkout`, `git reset` @@ -257,7 +257,7 @@ Unstaged changes after reset: M premierfichier.c ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -# Revenir en arrière dans l'historique (4/5) +# Revenir en arrière dans l'historique (4/6) ## Commandes: `git checkout`, `git reset` @@ -285,7 +285,7 @@ index 9622e40..cfd5469 100644 +Oh no! An awful modification! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -# Revenir en arrière dans l'historique (4/5) +# Revenir en arrière dans l'historique (5/6) ## Commandes: `git checkout`, `git reset` @@ -295,6 +295,103 @@ index 9622e40..cfd5469 100644 [tutorial]$ git commit -am "troisieme commit" [master 0563c02] troisieme commit 1 file changed, 1 insertion(+), 1 deletion(-) +[tutorial]$ git push [tutorial]$ git reset f9ab3ec4a00c46a12d7a45f133295acc5fb5cd20 +[tutorial]$ git status +On branch master +Your branch is behind 'origin/master' by 1 commit, and can be fast-forwarded. + (use "git pull" to update your local branch) + +Changes not staged for commit: + modified: premierfichier.c + +no changes added to commit [tutorial]$ git checkout premierfichier.c ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# Revenir en arrière dans l'historique (6/6) + +## Commandes: `git checkout`, `git reset` + +### Faire un `git commit` qu'on aurait pas dû faire. + +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.bash .numberLines} +[tutorial]$ echo Wonderful World > premierfichier.c +[tutorial]$ git commit -am "la bonne troisieme modification" +[master 1b42970] la bonne troisieme modification + 1 file changed, 1 insertion(+), 1 deletion(-) +[tutorial]$ git status +On branch master +Your branch and 'origin/master' have diverged, +and have 1 and 1 different commits each, respectively. + (use "git pull" to merge the remote branch into yours) + +nothing to commit, working tree clean +[tutorial]$ git pull +Auto-merging premierfichier.c +CONFLICT (content): Merge conflict in premierfichier.c +Automatic merge failed; fix conflicts and then commit the result. +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +### Il ne reste qu'à corriger le conflit et refaire un `git commit`, `git push` + +# 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. + +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.bash .numberLines} +[malaspor@perka tutorial]$ git rm premierfichier.c +rm 'premierfichier.c' +[malaspor@perka tutorial]$ git st +On branch master +Your branch is up to date with 'origin/master'. + +Changes to be committed: + (use "git reset HEAD <file>..." to unstage) + + deleted: premierfichier.c + +[malaspor@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 +[malaspor@perka tutorial]$ ls -ltr +total 0 +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# Retirer un fichier du contrôle de version (2/3) + +## Commande: `git rm` + +- Il n'est plus nécessaire de suivre un fichier. +- **Attention**: le fichier ne disparaît pas de l'historique. + +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.bash .numberLines} +[malaspor@perka tutorial]$ git reset bbb151324289dc2f85468f5721ec1021692dd216 +Unstaged changes after reset: +D premierfichier.c +[malaspor@perka tutorial]$ git status +On branch master +Your branch is up to date with 'origin/master'. + +Changes not staged for commit: + (use "git add/rm <file>..." to update what will be committed) + (use "git checkout -- <file>..." to discard changes in working directory) + + deleted: premierfichier.c + +no changes added to commit (use "git add" and/or "git commit -a") +[malaspor@perka tutorial]$ ls -ltr +total 0 +[malaspor@perka tutorial]$ git checkout premierfichier.c +[malaspor@perka tutorial]$ ls -ltr +total 4 +-rw-r--r-- 1 malaspor malaspor 17 5 mar 11:13 premierfichier.c +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + + +