Skip to content
Snippets Groups Projects
REDA_YOUSSEF.md 14.6 KiB
Newer Older
NIDABRAHIM Youssef's avatar
NIDABRAHIM Youssef committed
# Cours Forge ZZ2 F2 2017

# Infos étudiant :

Par binôme Nom Prénom:
NIDABRAHIM Youssef's avatar
NIDABRAHIM Youssef committed
 * Mohamed Reda BENCHRAA
 * Youssef NIDABRAHIM
NIDABRAHIM Youssef's avatar
NIDABRAHIM Youssef committed

## TP 1


Télécharger le sujet du TP à l'adresse suivante :
https://gitlab.isima.fr/mazenovi/2017-F2-Forge

#### 1. Les basiques
0. Créer un repository git
```
$ git init
Initialized empty Git repository in C:/TP1/.git/
```
0. _Par la suite pensez à commiter votre compte rendu apres chaques étapes dont l'enoncé est terminé par `*`, pour les messages de commit vous pouvez utiliser les numéros des questions (Ex Q1.2 ici)_

0. Ajouter le compte rendu dans le repo `*`
```
$ git add .
```
  > On commite cette étape Q1.3
```
$ git commit -m "Q1.3"
[master (root-commit) b0b4b05] Q1.3
 1 file changed, 258 insertions(+)
 create mode 100644 cr.md
```
NIDABRAHIM Youssef's avatar
NIDABRAHIM Youssef committed

NIDABRAHIM Youssef's avatar
NIDABRAHIM Youssef committed
0. Afficher la status de votre copie de travail
```
NIDABRAHIM Youssef's avatar
NIDABRAHIM Youssef committed
$ git status
On branch master
nothing to commit, working tree clean
NIDABRAHIM Youssef's avatar
NIDABRAHIM Youssef committed
```
NIDABRAHIM Youssef's avatar
NIDABRAHIM Youssef committed

NIDABRAHIM Youssef's avatar
NIDABRAHIM Youssef committed
0. Modifiez le CR pour supprimer la première partie et indiquez vos noms (n'oublier pas de faire un `git add` pour marque le fichier comme devant être ajouté) `*`
```
NIDABRAHIM Youssef's avatar
NIDABRAHIM Youssef committed
$ git add .
```
  > On commite cette étape Q1.5
NIDABRAHIM Youssef's avatar
NIDABRAHIM Youssef committed
```
NIDABRAHIM Youssef's avatar
NIDABRAHIM Youssef committed
$ git commit -m "Q1.5"
[master 6866275] Q1.5
 1 file changed, 7 insertions(+), 3 deletions(-)
```

NIDABRAHIM Youssef's avatar
NIDABRAHIM Youssef committed
0. Afficher l'historique de votre repo
```
NIDABRAHIM Youssef's avatar
NIDABRAHIM Youssef committed
$ git log
commit 80f71a0487d0b236a26bfd9e540582b68cad7943
Author: NIDABRAHIM Youssef <youssef.nidabrahim@um5s.net.ma>
Date:   Mon Feb 12 21:15:48 2018 +0100
    Q1.5
commit 3ec344ecfd24df41ca97396f27b52ec570297ce3
Author: NIDABRAHIM Youssef <youssef.nidabrahim@um5s.net.ma>
Date:   Mon Feb 12 21:02:43 2018 +0100
    Q1.3
NIDABRAHIM Youssef's avatar
NIDABRAHIM Youssef committed
```
NIDABRAHIM Youssef's avatar
NIDABRAHIM Youssef committed

NIDABRAHIM Youssef's avatar
NIDABRAHIM Youssef committed
0. Renommer ce fichier en préfixant avec vos noms en amendant le commit précédent (`git commit -m "mon message"` pour indiquer le mesage de commit directement) `*`
```
NIDABRAHIM Youssef's avatar
NIDABRAHIM Youssef committed
$ git mv cr.md REDA_YOUSSEF.md
$ git add *
NIDABRAHIM Youssef's avatar
NIDABRAHIM Youssef committed
```
NIDABRAHIM Youssef's avatar
NIDABRAHIM Youssef committed
  > On commite cette étape Q1.7 en amendant le commit précédent
```
$ git commit -m "Q1.7" --amend
[master abfd2d9] Q1.7
 Date: Mon Feb 12 21:15:48 2018 +0100
 1 file changed, 27 insertions(+), 8 deletions(-)
 rename cr.md => REDA_YOUSSEF.md (91%)
```

NIDABRAHIM Youssef's avatar
NIDABRAHIM Youssef committed
0. Afficher l'historique de votre repo
```
NIDABRAHIM Youssef's avatar
NIDABRAHIM Youssef committed
$ git log
commit abfd2d91c6fff3d02fd132e77c012cc695b2ec84
Author: NIDABRAHIM Youssef <youssef.nidabrahim@um5s.net.ma>
Date:   Mon Feb 12 21:15:48 2018 +0100
    Q1.7
commit 3ec344ecfd24df41ca97396f27b52ec570297ce3
Author: NIDABRAHIM Youssef <youssef.nidabrahim@um5s.net.ma>
Date:   Mon Feb 12 21:02:43 2018 +0100
    Q1.3
NIDABRAHIM Youssef's avatar
NIDABRAHIM Youssef committed
```
NIDABRAHIM Youssef's avatar
NIDABRAHIM Youssef committed
 > **NOTE:** On remarque bien que le commit Q1.5 est remplacer par celui de Q1.7

NIDABRAHIM Youssef's avatar
NIDABRAHIM Youssef committed
0. Il ne devrait y avoir que deux entrées dans l'historique pourquoi ? `*`
NIDABRAHIM Youssef's avatar
NIDABRAHIM Youssef committed
    > On doit y avoir exactement deux entrées dans l'historique `Q1.3` et `Q1.7` et cela parcequ'on avait remplacer le commit `Q1.5` par `Q1.7` en ajoutant `--amend` à la fin de la commande `commit`

    ```
NIDABRAHIM Youssef's avatar
NIDABRAHIM Youssef committed
$ git add *
$ git commit -m "Q1.9"
[master a38f03f] Q1.9
 1 file changed, 24 insertions(+), 3 deletions(-)
NIDABRAHIM Youssef's avatar
NIDABRAHIM Youssef committed
```
NIDABRAHIM Youssef's avatar
NIDABRAHIM Youssef committed

NIDABRAHIM Youssef's avatar
NIDABRAHIM Youssef committed
0. Créer un nouveau fichier, nommé start, contenant la date et l'heure actuelle `*`
```
NIDABRAHIM Youssef's avatar
NIDABRAHIM Youssef committed
$ touch start
$ date > start
$ git add .
warning: LF will be replaced by CRLF in start.
The file will have its original line endings in your working directory.
```
  > On commite cette étape Q1.10
```
NIDABRAHIM Youssef's avatar
NIDABRAHIM Youssef committed
$ git commit -m "Q1.10"
[master 51a5add] Q1.10
 2 files changed, 14 insertions(+), 5 deletions(-)
 create mode 100644 start
NIDABRAHIM Youssef's avatar
NIDABRAHIM Youssef committed
```
NIDABRAHIM Youssef's avatar
NIDABRAHIM Youssef committed

NIDABRAHIM Youssef's avatar
NIDABRAHIM Youssef committed
0. Créer un nouveau fichier : file2ignore
```
NIDABRAHIM Youssef's avatar
NIDABRAHIM Youssef committed
$  touch file2ignore
NIDABRAHIM Youssef's avatar
NIDABRAHIM Youssef committed
```
NIDABRAHIM Youssef's avatar
NIDABRAHIM Youssef committed

NIDABRAHIM Youssef's avatar
NIDABRAHIM Youssef committed
0. Afficher la status de votre copie de travail
```
NIDABRAHIM Youssef's avatar
NIDABRAHIM Youssef committed
$ git status
On branch 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:   REDA_YOUSSEF.md
Untracked files:
  (use "git add <file>..." to include in what will be committed)
        file2ignore
no changes added to commit (use "git add" and/or "git commit -a")
NIDABRAHIM Youssef's avatar
NIDABRAHIM Youssef committed
```
NIDABRAHIM Youssef's avatar
NIDABRAHIM Youssef committed

NIDABRAHIM Youssef's avatar
NIDABRAHIM Youssef committed
0. On souhaite que ce fichier soit ignoré et ne soit jamais commiter. Réalisez la configuration nécesaire pour que cette regle soit effective `*`
```
NIDABRAHIM Youssef's avatar
NIDABRAHIM Youssef committed
$ touch .gitignore
$ echo file2ignore > .gitignore
$ git add *
The following paths are ignored by one of your .gitignore files:
file2ignore
Use -f if you really want to add them.
```
  > On commite cette étape Q1.13
```
NIDABRAHIM Youssef's avatar
NIDABRAHIM Youssef committed
$ git commit -m "Q1.13"
[master 715a4ee] Q1.13
 1 file changed, 26 insertions(+), 6 deletions(-)
NIDABRAHIM Youssef's avatar
NIDABRAHIM Youssef committed
```
NIDABRAHIM Youssef's avatar
NIDABRAHIM Youssef committed

NIDABRAHIM Youssef's avatar
NIDABRAHIM Youssef committed
0. Lister le contenu du repertoire courant, afficher le status et la log
```
NIDABRAHIM Youssef's avatar
NIDABRAHIM Youssef committed
$ git ls-files
REDA_YOUSSEF.md
start
```
```
$ git status
On branch 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:   REDA_YOUSSEF.md
Untracked files:
  (use "git add <file>..." to include in what will be committed)
        .gitignore
no changes added to commit (use "git add" and/or "git commit -a")
NIDABRAHIM Youssef's avatar
NIDABRAHIM Youssef committed
```
NIDABRAHIM Youssef's avatar
NIDABRAHIM Youssef committed
```
$ git log
commit 715a4ee8285da57cd0debd02ef0d2756d7e9408a
Author: NIDABRAHIM Youssef <youssef.nidabrahim@um5s.net.ma>
Date:   Mon Feb 12 22:05:17 2018 +0100
    Q1.13
commit 51a5addb0f97faae02a4e72054fb4af151e41fd5
Author: NIDABRAHIM Youssef <youssef.nidabrahim@um5s.net.ma>
Date:   Mon Feb 12 21:53:17 2018 +0100
    Q1.10
commit a38f03f0e4779c9aec92bd1bd6dce92c18f03723
Author: NIDABRAHIM Youssef <youssef.nidabrahim@um5s.net.ma>
Date:   Mon Feb 12 21:40:41 2018 +0100
    Q1.9
commit abfd2d91c6fff3d02fd132e77c012cc695b2ec84
Author: NIDABRAHIM Youssef <youssef.nidabrahim@um5s.net.ma>
Date:   Mon Feb 12 21:15:48 2018 +0100
    Q1.7
:...skipping...
commit 715a4ee8285da57cd0debd02ef0d2756d7e9408a
Author: NIDABRAHIM Youssef <youssef.nidabrahim@um5s.net.ma>
Date:   Mon Feb 12 22:05:17 2018 +0100
    Q1.13
commit 51a5addb0f97faae02a4e72054fb4af151e41fd5
Author: NIDABRAHIM Youssef <youssef.nidabrahim@um5s.net.ma>
Date:   Mon Feb 12 21:53:17 2018 +0100
    Q1.10
commit a38f03f0e4779c9aec92bd1bd6dce92c18f03723
Author: NIDABRAHIM Youssef <youssef.nidabrahim@um5s.net.ma>
Date:   Mon Feb 12 21:40:41 2018 +0100
    Q1.9
commit abfd2d91c6fff3d02fd132e77c012cc695b2ec84
Author: NIDABRAHIM Youssef <youssef.nidabrahim@um5s.net.ma>
Date:   Mon Feb 12 21:15:48 2018 +0100
    Q1.7
commit 3ec344ecfd24df41ca97396f27b52ec570297ce3
Author: NIDABRAHIM Youssef <youssef.nidabrahim@um5s.net.ma>
Date:   Mon Feb 12 21:02:43 2018 +0100
    Q1.3
```

NIDABRAHIM Youssef's avatar
NIDABRAHIM Youssef committed
0. Avant de commiter affichez les modifications par rapport à la précédente révision ? `*`
```
NIDABRAHIM Youssef's avatar
NIDABRAHIM Youssef committed
 $ git diff
diff --git a/REDA_YOUSSEF.md b/REDA_YOUSSEF.md
index 26d82fc..50663bf 100644
--- a/REDA_YOUSSEF.md
+++ b/REDA_YOUSSEF.md
@@ -147,14 +147,70 @@ Use -f if you really want to add them.
 ```
   > On commite cette étape Q1.13
 ```
-git commit -m "Q1.13"
+$ git commit -m "Q1.13"
+[master 715a4ee] Q1.13
+ 1 file changed, 26 insertions(+), 6 deletions(-)
 ```
+
 0. Lister le contenu du repertoire courant, afficher le status et la log
 ```
-git ls-files
-git status
-git log
+$ git ls-files
+REDA_YOUSSEF.md
+start
+```
:...skipping...
diff --git a/REDA_YOUSSEF.md b/REDA_YOUSSEF.md
index 26d82fc..50663bf 100644
--- a/REDA_YOUSSEF.md
+++ b/REDA_YOUSSEF.md
@@ -147,14 +147,70 @@ Use -f if you really want to add them.
 ```
   > On commite cette étape Q1.13
 ```
-git commit -m "Q1.13"
+$ git commit -m "Q1.13"
+[master 715a4ee] Q1.13
+ 1 file changed, 26 insertions(+), 6 deletions(-)
 ```
+
 0. Lister le contenu du repertoire courant, afficher le status et la log
 ```
-git ls-files
-git status
-git log
+$ git ls-files
+REDA_YOUSSEF.md
+start
+```
+```
+$ git status
+On branch 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:   REDA_YOUSSEF.md
+Untracked files:
+  (use "git add <file>..." to include in what will be committed)
+        .gitignore
+no changes added to commit (use "git add" and/or "git commit -a")
+```
 ```
+$ git log
+commit 715a4ee8285da57cd0debd02ef0d2756d7e9408a
+Author: NIDABRAHIM Youssef <youssef.nidabrahim@um5s.net.ma>
+Date:   Mon Feb 12 22:05:17 2018 +0100
+    Q1.13
+commit 51a5addb0f97faae02a4e72054fb4af151e41fd5
+Author: NIDABRAHIM Youssef <youssef.nidabrahim@um5s.net.ma>
+Date:   Mon Feb 12 21:53:17 2018 +0100
+    Q1.10
+commit a38f03f0e4779c9aec92bd1bd6dce92c18f03723
+Author: NIDABRAHIM Youssef <youssef.nidabrahim@um5s.net.ma>
+Date:   Mon Feb 12 21:40:41 2018 +0100
+    Q1.9
+commit abfd2d91c6fff3d02fd132e77c012cc695b2ec84
+Author: NIDABRAHIM Youssef <youssef.nidabrahim@um5s.net.ma>
+Date:   Mon Feb 12 21:15:48 2018 +0100
+    Q1.7
+:...skipping...
+commit 715a4ee8285da57cd0debd02ef0d2756d7e9408a
+Author: NIDABRAHIM Youssef <youssef.nidabrahim@um5s.net.ma>
+Date:   Mon Feb 12 22:05:17 2018 +0100
+    Q1.13
+commit 51a5addb0f97faae02a4e72054fb4af151e41fd5
+Author: NIDABRAHIM Youssef <youssef.nidabrahim@um5s.net.ma>
+Date:   Mon Feb 12 21:53:17 2018 +0100
+    Q1.10
+commit a38f03f0e4779c9aec92bd1bd6dce92c18f03723
+Author: NIDABRAHIM Youssef <youssef.nidabrahim@um5s.net.ma>
+Date:   Mon Feb 12 21:40:41 2018 +0100
+    Q1.9
+commit abfd2d91c6fff3d02fd132e77c012cc695b2ec84
+Author: NIDABRAHIM Youssef <youssef.nidabrahim@um5s.net.ma>
+Date:   Mon Feb 12 21:15:48 2018 +0100
+    Q1.7
+commit 3ec344ecfd24df41ca97396f27b52ec570297ce3
+Author: NIDABRAHIM Youssef <youssef.nidabrahim@um5s.net.ma>
+Date:   Mon Feb 12 21:02:43 2018 +0100
+    Q1.3
+```
+
 0. Avant de commiter affichez les modifications par rapport à la précédente révision ? `*`
 ```
 git diff
```
```
NIDABRAHIM Youssef's avatar
NIDABRAHIM Youssef committed
$ git add *
The following paths are ignored by one of your .gitignore files:
file2ignore
Use -f if you really want to add them.
NIDABRAHIM Youssef's avatar
NIDABRAHIM Youssef committed
```
NIDABRAHIM Youssef's avatar
NIDABRAHIM Youssef committed
  > On commite cette étape Q1.15
NIDABRAHIM Youssef's avatar
NIDABRAHIM Youssef committed
```
NIDABRAHIM Youssef's avatar
NIDABRAHIM Youssef committed
$ git commit -m "Q1.15"
[master 717b390] Q1.15
 1 file changed, 168 insertions(+), 5 deletions(-)
NIDABRAHIM Youssef's avatar
NIDABRAHIM Youssef committed
```

##### 2. Les branches
0. Créez une branche portant votre nom et basculer sur cette branche (dans la suite du TP cette branche est désignée par `mybranch`)
```
NIDABRAHIM Youssef's avatar
NIDABRAHIM Youssef committed
$ git branch reda_youssef
$ git checkout reda_youssef
Switched to branch 'reda_youssef'
M       REDA_YOUSSEF.md
NIDABRAHIM Youssef's avatar
NIDABRAHIM Youssef committed
```
NIDABRAHIM Youssef's avatar
NIDABRAHIM Youssef committed

NIDABRAHIM Youssef's avatar
NIDABRAHIM Youssef committed
0. Lister les branches locales et les fichiers présent dans le répertoire courant `*`
```
NIDABRAHIM Youssef's avatar
NIDABRAHIM Youssef committed
$ git branch
  master
* reda_youssef
```
```
$ git ls-files
REDA_YOUSSEF.md
start
```
```
$ git add .
warning: LF will be replaced by CRLF in .gitignore.
The file will have its original line endings in your working directory.
```
  >
```
NIDABRAHIM Youssef's avatar
NIDABRAHIM Youssef committed
```
NIDABRAHIM Youssef's avatar
NIDABRAHIM Youssef committed
  
NIDABRAHIM Youssef's avatar
NIDABRAHIM Youssef committed
0. Aficher le status de votre repo `*`
```
git status
```
0. Créez une branche pour _développer_ la réponse de ce point (nommez là `mybranch-2.4` par exemple)
  ```
  git branch -b reda_youssef_2
  ```
  0. Afficher un historique sous forme de graph (`a dog`) de votre repo
  ```
  git log --all --graph --decorate --oneline
  ```
  0. Pourquoi les 2 branches pointent elles sur la même révision ?`*`
  ```
  car il y a pas de changement
  ```
  0. Afficher à nouvea l'historique pour montrer les modifications suite au précédent commit `*`
  ```
  git add .
  git commit -m "Q2.4.3"
  git log --graph --abbrev-commit --decorate
  ```
  0. Pourquoi les 2 branches pointent elles sur la même révision ?`*`
  ```
  car il y a pas de changement
  ```
  0. Afficher à nouvea l'historique pour montrer les modifications suite au précédent commit `*`
0. Revenir la brache `mybranch`
```
git checkout reda_youssef
```
0. Où sont passé vos reponces au point 2.4 ? `*`
```
git add .
git commit -m "Q2.6"
```
0. Affichez un historique sous forme de graph (`a dog`) de votre repo, Que peux ton en dire ?
```
git log --all --graph --decorate --oneline
```
0. Revenir sur la branche master
```
git checkout master
```
0. Ajoutez et commitez un fichier (touch new_file)
```
touch new_file
git add .
git commit -m "Q2.9"
```
0. Revenir sur votre branche `mybranch` pour completer le compte rendu `*`
```
git checkout reda_youssef
```
0. Affichez un historique sous forme de graph (`a dog`) de votre repo `*`
```
git log --all --graph --decorate --oneline
```

##### 3. Merge
0. Merge depuis head
  0. switcher sur une nouvelle branche `mybranch-3.1`
  ```
  git brach -b reda_youssef_3
  ```
  0. ajout un nouveau fichier nommé easy_merge avec la date et l'heure actuelle `*`
  ```
  touch easy_merge
  date > easy_merge
  git add .
  git commit -m "Q3.1.2"
  ```
  0. merger la branche `mybranch-4.1` sur `mybranch`
  ```
  git checkout reda_youssef
  git merge reda_youssef_3
  ```
0. Afficher le status
```
git status
```
0. Pourquoi n'y a t'il aucune modification en cours ? `*`
```
can on a rien fait sur la branche reda_youssef
git add .
git commit -m "Q3.3"
```
0. Affichez un historique sous forme de graph (`a dog`) de votre repo et décire l'état courant`*`
```
git log --all --graph --decorate --oneline
git add .
git commit -m "Q3.4"
```
0. Merge avec modifications
  0. Mergez les modifications de la branche `mybranch-2.4` sur `mybranch` (`*echap* :wq *enter*` pour sauvegarder le message de commit et quitter)`*`
  ```
  git checkout reda_youssef
  git branch reda_youssef2
  git add .
  git commit -m "Q3.5.1"
  ```
  0. Affichez un historique sous forme de graph (`a dog`) de votre repo `*`
  ```
  git log --all --graph --decorate --oneline
  git add .
  git commit -m "Q3.5.2"
  ```
0. Merge avec conflit
  0. Céer une nouvelle branche `mybranch-3.6`
  ```
  git branch reda_youssef_3.6
  ```
  0. Notez dans le CR la date et l'heure actuelle (avec la commande `date` par exemple) `*`
  ```
  date > BENCHRAA_NIDABRAHIM.md
  ```
  0. Switchez sur la nouvelle branche et modifiez la réponse précendante dans le CR avec le `*`
  ```
  git checkout reda_youssef_3.6
  date > BENCHRAA_NIDABRAHIM
  ```
  0. Réalisez le merge de la brache `mybranch-3.6` sur `mybranch`. Le prompt change, pourquoi ? Gerer le conflit et commiter.
  ```
  git checkout reda_youssef
  git merge reda_youssef_3.6
  ```
0. Supprimer les branches de feature et afficher toutes les branches restantes, affichez un historique sous forme de graph (`a dog`) de votre repo `*`
```
  git branch -D reda_youssef_2
  git branch -D reda_youssef_3
  git branch -D reda_youssef_3.6
  git log --all --graph --decorate --oneline
```

##### 4. Remote
0. Afficher l'historique de votre repo
```
git log --all --graph --decorate --oneline
```
0. Ajouter le projet "2017-F2-Forge" comme repository distant `*`
```
git remote add origin https://mobenchraa@gitlab.isima.fr/mazenovi/2017-F2-Forge.git
git add .
git commit -m
```
0. Lister les branches distantes
```
git remote show https://mobenchraa@gitlab.isima.fr/mazenovi/2017-F2-Forge.git
```
0. Pousser votre branche de votre repo local sur le repos distant `*`
```
git add .
git commit -m
git push origin reda_youssef
```
0. En consultant votre branche sous gitlab, vous devriez constaté que la date de modification du fichier start est plus acienne que celle de votre compte rendu, porquoi alors que le push de toute votre branche est faite en une seule fois ?
```
git trace les modifications et pas les fichiers
```
0. Supprimer le dossier .git
0. Faire un git status ?