Skip to content
Snippets Groups Projects
Commit 6ca22bdd authored by NIDABRAHIM Youssef's avatar NIDABRAHIM Youssef
Browse files

Uploading TPs code files

parent d2eda70d
No related tags found
No related merge requests found
file2ignore
# Cours Forge ZZ2 F2 2017
# Infos étudiant :
Par binôme Nom Prénom:
* Mohamed Reda BENCHRAA
* Youssef NIDABRAHIM
## 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
```
0. Afficher la status de votre copie de travail
```
$ git status
On branch master
nothing to commit, working tree clean
```
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é) `*`
```
$ git add .
```
> On commite cette étape Q1.5
```
$ git commit -m "Q1.5"
[master 6866275] Q1.5
1 file changed, 7 insertions(+), 3 deletions(-)
```
0. Afficher l'historique de votre repo
```
$ 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
```
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) `*`
```
$ git mv cr.md REDA_YOUSSEF.md
$ git add *
```
> 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%)
```
0. Afficher l'historique de votre repo
```
$ 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
```
> **NOTE:** On remarque bien que le commit Q1.5 est remplacer par celui de Q1.7
0. Il ne devrait y avoir que deux entrées dans l'historique pourquoi ? `*`
> 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`
```
$ git add *
$ git commit -m "Q1.9"
[master a38f03f] Q1.9
1 file changed, 24 insertions(+), 3 deletions(-)
```
0. Créer un nouveau fichier, nommé start, contenant la date et l'heure actuelle `*`
```
$ 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
```
$ git commit -m "Q1.10"
[master 51a5add] Q1.10
2 files changed, 14 insertions(+), 5 deletions(-)
create mode 100644 start
```
0. Créer un nouveau fichier : file2ignore
```
$ touch file2ignore
```
0. Afficher la status de votre copie de travail
```
$ 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")
```
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 `*`
```
$ 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
```
$ 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
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
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.15
```
$ git commit -m "Q1.15"
$ git commit -m "Q1.15"
[master 715a4ee] Q1.15
1 file changed, 26 insertions(+), 6 deletions(-)
```
0. Lister le contenu du repertoire courant, afficher le status et la log
```
$ git ls-files
REDA_YOUSSEF.md
start
```
```
$ git log
:...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.16
```
git commit -m "Q1.16"
$ git commit -m "Q1.16"
[master 715a4ee] Q1.16
1 file changed, 26 insertions(+), 6 deletions(-)
```
0. Lister le contenu du repertoire courant, afficher le status et la 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
```
```
$ 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.18
```
$ git commit -m "Q1.18"
[master 717b390] Q1.18
1 file changed, 168 insertions(+), 5 deletions(-)
```
##### 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`)
```
$ git branch reda_youssef
$ git checkout reda_youssef
Switched to branch 'reda_youssef'
M REDA_YOUSSEF.md
```
0. Lister les branches locales et les fichiers présent dans le répertoire courant `*`
```
$ 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.
```
> On commite cette étape Q2.2
```
$ git commit -m "Q2.2"
[reda_youssef 03c3017] Q2.2
2 files changed, 31 insertions(+), 4 deletions(-)
create mode 100644 .gitignore
```
0. Afficher le status de votre repo `*`
```
$ git status
On branch reda_youssef
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
no changes added to commit (use "git add" and/or "git commit -a")
```
> On commite cette étape Q2.3
```
$ git commit -m "Q2.3"
[reda_youssef 71592a8] Q2.3
1 file changed, 21 insertions(+), 3 deletions(-)
```
0. Créez une branche pour _développer_ la réponse de ce point (nommez là `mybranch-2.4` par exemple)
```
$ git branch reda_youssef-2.4
```
0. Afficher un historique sous forme de graph (`a dog`) de votre repo
```
$ git log --all --graph --decorate --oneline
*71592a8 (HEAD -> reda_youssef-2.4, reda_youssef) Q2.3
*03c3017 Q2.2
*717b390 (master) Q1.15
*715a4ee Q1.13
*51a5add Q1.10
*a38f03f Q1.9
*abfd2d9 Q1.7
*3ec344e Q1.3
```
0. Pourquoi les 2 branches pointent elles sur la même révision ?`*`
> On remarque que les 2 branches `reda_youssef` et `reda_youssef-2.4` pointent sur la même révision puisque il n'y pas de `commit`
```
$ git add .
$ git commit -m "Q2.4.2"
[reda_youssef-2.4 12bae9c] Q2.4.2
1 file changed, 186 insertions(+), 14 deletions(-)
```
0. Afficher à nouveau l'historique pour montrer les modifications suite au précédent commit `*`
```
$ git log --graph --abbrev-commit --decorate
*commit 12bae9c (HEAD -> reda_youssef-2.4)
|Author: NIDABRAHIM Youssef <youssef.nidabrahim@um5s.net.ma>
|Date: Mon Feb 12 23:00:27 2018 +0100
|
| Q2.4.2
|
*commit 71592a8 (reda_youssef)
|Author: NIDABRAHIM Youssef <youssef.nidabrahim@um5s.net.ma>
|Date: Mon Feb 12 22:21:41 2018 +0100
|
| Q2.3
|
*commit 03c3017
|Author: NIDABRAHIM Youssef <youssef.nidabrahim@um5s.net.ma>
|Date: Mon Feb 12 22:19:47 2018 +0100
|
| Q2.2
|
*commit 717b390 (master)
|Author: NIDABRAHIM Youssef <youssef.nidabrahim@um5s.net.ma>
|Date: Mon Feb 12 22:14:02 2018 +0100
|
| Q1.15
:...skipping...
*commit 12bae9c (HEAD -> reda_youssef-2.4)
|Author: NIDABRAHIM Youssef <youssef.nidabrahim@um5s.net.ma>
|Date: Mon Feb 12 23:00:27 2018 +0100
|
| Q2.4.2
|
*commit 71592a8 (reda_youssef)
|Author: NIDABRAHIM Youssef <youssef.nidabrahim@um5s.net.ma>
|Date: Mon Feb 12 22:21:41 2018 +0100
|
| Q2.3
|
*commit 03c3017
|Author: NIDABRAHIM Youssef <youssef.nidabrahim@um5s.net.ma>
|Date: Mon Feb 12 22:19:47 2018 +0100
|
| Q2.2
|
*commit 717b390 (master)
|Author: NIDABRAHIM Youssef <youssef.nidabrahim@um5s.net.ma>
|Date: Mon Feb 12 22:14:02 2018 +0100
|
| Q1.15
|
*commit 715a4ee
|Author: NIDABRAHIM Youssef <youssef.nidabrahim@um5s.net.ma>
|Date: Mon Feb 12 22:05:17 2018 +0100
|
| Q1.13
|
*commit 51a5add
|Author: NIDABRAHIM Youssef <youssef.nidabrahim@um5s.net.ma>
|Date: Mon Feb 12 21:53:17 2018 +0100
|
| Q1.10
|
*commit a38f03f
|Author: NIDABRAHIM Youssef <youssef.nidabrahim@um5s.net.ma>
|Date: Mon Feb 12 21:40:41 2018 +0100
|
| Q1.9
|
*commit abfd2d9
|Author: NIDABRAHIM Youssef <youssef.nidabrahim@um5s.net.ma>
|Date: Mon Feb 12 21:15:48 2018 +0100
|
| Q1.7
|
*commit 3ec344e
Author: NIDABRAHIM Youssef <youssef.nidabrahim@um5s.net.ma>
Date: Mon Feb 12 21:02:43 2018 +0100
Q1.3
```
> On commite cette étape Q2.4.3
```
$ git add .
$ git commit -m "Q2.4.3"
[reda_youssef-2.4 3dd3708] Q2.4.3
1 file changed, 10 insertions(+), 11 deletions(-)
```
0. Pourquoi les 2 branches pointent elles sur la même révision ?`*`
> Car il n'y a pas de changement
```
$ git add .
$ git commit -m "Q2.4.4"
[reda_youssef-2.4 d72c9c1] Q2.4.4
1 file changed, 3 insertions(+), 3 deletions(-)
```
0. Afficher à nouveau l'historique pour montrer les modifications suite au précédent commit `*`
```
$ git log --graph --abbrev-commit --decorate
*commit d72c9c1 (HEAD -> reda_youssef-2.4)
|Author: NIDABRAHIM Youssef <youssef.nidabrahim@um5s.net.ma>
|Date: Mon Feb 12 23:04:18 2018 +0100
|
| Q2.4.4
|
*commit 3dd3708
|Author: NIDABRAHIM Youssef <youssef.nidabrahim@um5s.net.ma>
|Date: Mon Feb 12 23:03:02 2018 +0100
|
| Q2.4.3
|
*commit 12bae9c
|Author: NIDABRAHIM Youssef <youssef.nidabrahim@um5s.net.ma>
|Date: Mon Feb 12 23:00:27 2018 +0100
|
| Q2.4.2
|
*commit 71592a8 (reda_youssef)
|Author: NIDABRAHIM Youssef <youssef.nidabrahim@um5s.net.ma>
|Date: Mon Feb 12 22:21:41 2018 +0100
|
| Q2.3
:...skipping...
*commit d72c9c1 (HEAD -> reda_youssef-2.4)
|Author: NIDABRAHIM Youssef <youssef.nidabrahim@um5s.net.ma>
|Date: Mon Feb 12 23:04:18 2018 +0100
|
| Q2.4.4
|
*commit 3dd3708
|Author: NIDABRAHIM Youssef <youssef.nidabrahim@um5s.net.ma>
|Date: Mon Feb 12 23:03:02 2018 +0100
|
| Q2.4.3
|
*commit 12bae9c
|Author: NIDABRAHIM Youssef <youssef.nidabrahim@um5s.net.ma>
|Date: Mon Feb 12 23:00:27 2018 +0100
|
| Q2.4.2
|
*commit 71592a8 (reda_youssef)
|Author: NIDABRAHIM Youssef <youssef.nidabrahim@um5s.net.ma>
|Date: Mon Feb 12 22:21:41 2018 +0100
|
| Q2.3
|
*commit 03c3017
|Author: NIDABRAHIM Youssef <youssef.nidabrahim@um5s.net.ma>
|Date: Mon Feb 12 22:19:47 2018 +0100
|
| Q2.2
|
*commit 717b390 (master)
|Author: NIDABRAHIM Youssef <youssef.nidabrahim@um5s.net.ma>
|Date: Mon Feb 12 22:14:02 2018 +0100
|
| Q1.15
|
*commit 715a4ee
|Author: NIDABRAHIM Youssef <youssef.nidabrahim@um5s.net.ma>
|Date: Mon Feb 12 22:05:17 2018 +0100
|
| Q1.13
|
*commit 51a5add
|Author: NIDABRAHIM Youssef <youssef.nidabrahim@um5s.net.ma>
|Date: Mon Feb 12 21:53:17 2018 +0100
|
| Q1.10
|
*commit a38f03f
|Author: NIDABRAHIM Youssef <youssef.nidabrahim@um5s.net.ma>
|Date: Mon Feb 12 21:40:41 2018 +0100
|
| Q1.9
|
*commit abfd2d9
|Author: NIDABRAHIM Youssef <youssef.nidabrahim@um5s.net.ma>
|Date: Mon Feb 12 21:15:48 2018 +0100
|
| Q1.7
|
*commit 3ec344e
Author: NIDABRAHIM Youssef <youssef.nidabrahim@um5s.net.ma>
Date: Mon Feb 12 21:02:43 2018 +0100
Q1.3
(END)
```
> On commite cette étape Q2.4.5
```
$ git add .
$ git commit -m "Q2.4.5"
[reda_youssef-2.4 f94d5dd] Q2.4.5
1 file changed, 41 insertions(+), 10 deletions(-)
```
0. Revenir la brache `mybranch`
```
$ git checkout reda_youssef
Switched to branch 'reda_youssef'
```
0. Où sont passé vos reponces au point 2.4 ? `*`
> Les réponces au point 2.4 sont dans l'autre branche `reda_youssef-2.4`
```
$ git add .
$ git commit -m "Q2.6"
[reda_youssef 30c07dd] Q2.6
1 file changed, 4 insertions(+), 1 deletion(-)
```
0. Affichez un historique sous forme de graph (`a dog`) de votre repo, Que peux ton en dire ?
```
$ git log --all --graph --decorate --oneline
*30c07dd (HEAD -> reda_youssef) Q2.6
| *02a31d5 (reda_youssef-2.4) Q2.4.5
| *d72c9c1 Q2.4.4
| *3dd3708 Q2.4.3
| *12bae9c Q2.4.2
|/
*71592a8 Q2.3
*03c3017 Q2.2
*717b390 (master) Q1.15
*715a4ee Q1.13
*51a5add Q1.10
*a38f03f Q1.9
*abfd2d9 Q1.7
*3ec344e Q1.3
```
> **NOTE:** D'après le graphe, on remarque bien les commites effectuer dans la branche `reda_youssef-2.4`
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
Switched to branch 'reda_youssef'
```
> On commite cette étape Q2.10
```
$ git add .
$ git commit -m "Q2.10"
[reda_youssef ca0e5da] Q2.10
1 file changed, 5 insertions(+), 1 deletion(-)
```
0. Affichez un historique sous forme de graph (`a dog`) de votre repo `*`
```
$ git log --all --graph --decorate --oneline
*ca0e5da (HEAD -> reda_youssef) Q2.10
*f50a0e6 Q2.6
| *b2acb20 (master) Q2.9
| | *02a31d5 (reda_youssef-2.4) Q2.4.5
| | *d72c9c1 Q2.4.4
| | *3dd3708 Q2.4.3
| | *12bae9c Q2.4.2
| |/
|/|
*|71592a8 Q2.3
*|03c3017 Q2.2
|/
*717b390 Q1.15
*715a4ee Q1.13
*51a5add Q1.10
*a38f03f Q1.9
*abfd2d9 Q1.7
*3ec344e Q1.3
```
> On commite cette étape Q2.11
```
$ git add .
$ git commit -m "Q2.11"
[reda_youssef 6dae183] Q2.11
1 file changed, 27 insertions(+), 1 deletion(-)
```
##### 3. Merge
0. Merge depuis head
0. switcher sur une nouvelle branche `mybranch-3.1`
```
$ git checkout -b reda_youssef-3.1
Switched to a new branch 'reda_youssef-3.1'
```
0. ajout un nouveau fichier nommé easy_merge avec la date et l'heure actuelle `*`
```
$ touch easy_merge
$ date > easy_merge
```
> On commite cette étape Q3.1.2
```
$ git add .
$ git commit -m "Q3.1.2"
[reda_youssef-3.1 3288cda] Q3.1.2
2 files changed, 9 insertions(+), 3 deletions(-)
create mode 100644 easy_merge
```
0. merger la branche `mybranch-3.1` sur `mybranch`
```
$ git checkout reda_youssef
Switched to branch 'reda_youssef'
```
```
$ git merge reda_youssef-3.1
Updating f258f21..4a165c0
Fast-forward
REDA_YOUSSEF.md | 21 +++++++++++++++------
easy_merge | 1 +
2 files changed, 16 insertions(+), 6 deletions(-)
```
0. Afficher le status
```
$ git status
On branch reda_youssef
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
no changes added to commit (use "git add" and/or "git commit -a")
```
0. Pourquoi n'y a t'il aucune modification en cours ? `*`
> Normalement, on n'aura pas de modification à commiter après un merge puisqu'ils sont déjà commiter dans la branche `reda_youssef-3.1`
```
$ git add .
$ git commit -m "Q3.3"
[reda_youssef b73a302] Q3.3
1 file changed, 21 insertions(+), 5 deletions(-)
```
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
*b73a302 (HEAD -> reda_youssef) Q3.3
*4a165c0 (reda_youssef-3.1) Q3.1.2
*f258f21 Q2.11
*ca0e5da Q2.10
*f50a0e6 Q2.6
| *b2acb20 (master) Q2.9
| | *02a31d5 (reda_youssef-2.4) Q2.4.5
| | *d72c9c1 Q2.4.4
| | *3dd3708 Q2.4.3
| | *12bae9c Q2.4.2
| |/
|/|
*|71592a8 Q2.3
*|03c3017 Q2.2
|/
*717b390 Q1.15
*715a4ee Q1.13
*51a5add Q1.10
*a38f03f Q1.9
*abfd2d9 Q1.7
*3ec344e Q1.3
```
> **NOTE:** On voit clairement que les commites de la branche `reda_youssef-3.1` sont ajouter à notre branche `reda_youssef`
```
$ git add .
$ git commit -m "Q3.4"
[reda_youssef 09aa3ac] Q3.4
1 file changed, 33 insertions(+), 5 deletions(-)
```
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 merge reda_youssef-2.4
Auto-merging REDA_YOUSSEF.md
Merge made by the 'recursive' strategy.
REDA_YOUSSEF.md | 236 ++++++++++++++++++++++++++++++++++++++++++++++++++++----
1 file changed, 219 insertions(+), 17 deletions(-)
```
> On commite cette étape Q3.5.1
```
$ git add .
$ git commit -m "Q3.5.1"
[reda_youssef 04680c8] Q3.5.1
1 file changed, 8 insertions(+), 2 deletions(-)
```
0. Affichez un historique sous forme de graph (`a dog`) de votre repo `*`
```
$ git log --all --graph --decorate --oneline
*04680c8 (HEAD -> reda_youssef) Q3.5.1
*563d694 Merge branch 'reda_youssef-2.4' into reda_youssef
|\
| *02a31d5 (reda_youssef-2.4) Q2.4.5
| *d72c9c1 Q2.4.4
| *3dd3708 Q2.4.3
| *12bae9c Q2.4.2
.* |cbc5756 Q3.4
.* |b73a302 Q3.3
.* |4a165c0 (reda_youssef-3.1) Q3.1.2
.* |f258f21 Q2.11
.* |ca0e5da Q2.10
.* |f50a0e6 Q2.6
|/
*71592a8 Q2.3
*03c3017 Q2.2
| *b2acb20 (master) Q2.9
|/
*717b390 Q1.15
*715a4ee Q1.13
*51a5add Q1.10
*a38f03f Q1.9
*abfd2d9 Q1.7
*3ec344e Q1.3
```
> On commite cette étape Q3.5.2
```
$ git add .
$ git commit -m "Q3.5.2"
[reda_youssef 1c24ed3] Q3.5.2
1 file changed, 35 insertions(+), 4 deletions(-)
```
0. Merge avec conflit
0. Céer une nouvelle branche `mybranch-3.6`
```
$ git branch reda_youssef-3.6
Created a new branch 'reda_youssef-3.6'
M REDA_YOUSSEF.md
```
0. Notez dans le CR la date et l'heure actuelle (avec la commande `date` par exemple) `*`
```
$ date >> REDA_YOUSSEF.md
```
> On commite cette étape Q3.6.2
```
$ git add .
$ git commit -m "Q3.6.2"
[reda_youssef 493cb2e] Q3.6.2
1 file changed, 22 insertions(+), 6 deletions(-)
```
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 >> REDA_YOUSSEF.md
```
> On commite cette étape Q3.6.3
```
$ git add .
$ git commit -m "Q3.6.3"
[reda_youssef-3.6 66764c5] Q3.6.3
1 file changed, 6 insertions(+), 2 deletions(-)
```
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
Switched to branch 'reda_youssef'
M REDA_YOUSSEF.md
$ git merge reda_youssef-3.6
Auto-merging REDA_YOUSSEF.md
CONFLICT (content): Merge conflict in REDA_YOUSSEF.md
Automatic merge failed; fix conflicts and then commit the result.
```
> **NOTE:** Le prompt change puisque les deux branches ont modifié la même chose
```
$ git add .
$ git commit -m "Q3.6.4"
[reda_youssef eef8621] Q3.6.4
```
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-3.6
Deleted branch reda_youssef-3.6 (was 25af935).
$ git branch -d reda_youssef-3.1
Deleted branch reda_youssef-3.1 (was 4a165c0).
$ git branch -d reda_youssef-2.4
Deleted branch reda_youssef-2.4 (was 02a31d5).
```
```
$ git log --all --graph --decorate --oneline
*eef8621 (HEAD -> reda_youssef) Q3.6.4
|\
| *25af935 Q3.6.3
.* |28c47b8 Q3.6.2
|/
*1c24ed3 Q3.5.2
*04680c8 Q3.5.1
*563d694 Merge branch 'reda_youssef-2.4' into reda_youssef
|\
| *02a31d5 Q2.4.5
| *d72c9c1 Q2.4.4
| *3dd3708 Q2.4.3
| *12bae9c Q2.4.2
.* |cbc5756 Q3.4
.* |b73a302 Q3.3
.* |4a165c0 Q3.1.2
.* |f258f21 Q2.11
.* |ca0e5da Q2.10
.* |f50a0e6 Q2.6
|/
*71592a8 Q2.3
*03c3017 Q2.2
| *b2acb20 (master) Q2.9
|/
*717b390 Q1.15
*715a4ee Q1.13
*51a5add Q1.10
*a38f03f Q1.9
*abfd2d9 Q1.7
*3ec344e Q1.3
```
> On commite cette étape Q3.7
```
$ git add .
$ git commit -m "Q3.7"
[reda_youssef 914b6e2] Q3.7
1 file changed, 47 insertions(+), 4 deletions(-)
```
##### 4. Remote
0. Afficher l'historique de votre repo
```
$ git log --all --graph --decorate --oneline
*3732bd6 (HEAD -> reda_youssef) Q3.7
*eef8621 Q3.6.4
|\
| *25af935 Q3.6.3
.* |28c47b8 Q3.6.2
|/
*1c24ed3 Q3.5.2
*04680c8 Q3.5.1
*563d694 Merge branch 'reda_youssef-2.4' into reda_youssef
|\
| *02a31d5 Q2.4.5
| *d72c9c1 Q2.4.4
| *3dd3708 Q2.4.3
| *12bae9c Q2.4.2
.* |cbc5756 Q3.4
.* |b73a302 Q3.3
.* |4a165c0 Q3.1.2
.* |f258f21 Q2.11
.* |ca0e5da Q2.10
.* |f50a0e6 Q2.6
|/
*71592a8 Q2.3
*03c3017 Q2.2
| *b2acb20 (master) Q2.9
|/
*717b390 Q1.15
*715a4ee Q1.13
*51a5add Q1.10
*a38f03f Q1.9
*abfd2d9 Q1.7
*3ec344e Q1.3
```
0. Ajouter le projet "2017-F2-Forge" comme repository distant `*`
```
$ git remote add origin https://mobenchraa@gitlab.isima.fr/mazenovi/2017-F2-Forge.git
```
> On commite cette étape Q4.2
```
$ git add .
$ git commit -m "Q4.2"
```
0. Lister les branches distantes
```
$ git remote add origin https://gitlab.isima.fr/mazenovi/2017-F2-Forge.git
```
0. Pousser votre branche de votre repo local sur le repos distant `*`
```
$ git push origin reda_youssef
Counting objects: 81, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (75/75), done.
Writing objects: 100% (81/81), 16.62 KiB | 0 bytes/s, done.
Total 81 (delta 36), reused 0 (delta 0)
remote:
remote: View merge request for reda_youssef:
remote: https://gitlab.isima.fr/mazenovi/2017-F2-Forge/merge_requests/5
remote:
To gitlab.isima.fr:mazenovi/2017-F2-Forge.git
* [new branch] reda_youssef -> reda_youssef
```
```
$ git add .
$ git commit -m "Q4.4"
[reda_youssef 44c6616] Q4.4
1 file changed, 1 insertion(+), 1 deletion(-)
$ 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, pourquoi alors que le push de toute votre branche est faite en une seule fois ?
> Avec git, les fichiers ne sont jamais tracé mais plutôt leurs modifications, cela veut dire que la date de modification du fichier start correspond à sa commit et non au dernier commit
0. Supprimer le dossier .git
```
$ rm -rf .git
```
0. Faire un git status ?
```
$ git status
fatal: Not a git repository (or any of the parent directories): .git
```
> **NOTE: ** C'est normal puisque le fichier `.git` a été supprimé, git ne reconnue plus notre répertoire donc il faut cloner notre branch comme suit :
```
$ git clone -b reda_youssef git@gitlab.isima.fr:mazenovi/2017-F2-Forge.git
```
```
$ git push origin reda_youssef
Counting objects: 4, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 716 bytes | 0 bytes/s, done.
Total 4 (delta 3), reused 0 (delta 0)
remote:
remote: View merge request for reda_youssef:
remote: https://gitlab.isima.fr/mazenovi/2017-F2-Forge/merge_requests/5
remote:
To gitlab.isima.fr:mazenovi/2017-F2-Forge.git
24c0277..01fbcce reda_youssef -> reda_youssef
```
lun. 12 févr. 2018 23:34:01
lun. 12 févr. 2018 21:48:10
# Cours Forge ZZ2 F2 2017
# Infos étudiant :
Par binôme Nom Prénom:
* Nom Prénom
* Nom Prénom
## Première partie - Consignes générales
### Format du document
Ce TP est et son compte rendu est un fichier au format `md` pour **Markdown** qui est un format permettant de gérérer facilement du HTML. Ce format étant couramment supporté par les outils de développement, nous l'utiliserons pour les comptes rendus.
Plus d'information sur la syntaxe de ce format :
* Spécification : https://daringfireball.net/projects/markdown/
* Cheatsheet : https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet
* Version GitLab : https://docs.gitlab.com/ee/user/markdown.html#code-and-syntax-highlighting
Ci dessous un exemple d’éditeur à utiliser pour obtenir une prés visualisation de votre document :
* **Atom** avec le plugin **markdown-preview**
* ctrl-shift-M pour afficher la preview
* **Notepad++** avec le plugin **MarkdownViewerPlusPlus**
* **SublimeText** avec le plugin **sublimetext-markdown-preview**
* **Eclipse**
* **IntelliJ**
* **vi / blocnote**
* ...
* Snipplet de code
### Format md
#### Exemple de code
```java
// ceci est un commentaire
public String test = "Hello Word";
boolean hello = true;
if (true == hello ) {
System.out.println(test);
}
```
##### Utilisation de liste
0. item 1
0. item 1.1
0. item 2
* liste
* non ordonné
* sans index
##### Accentuation
Italic avec *étoile* or _tiret-bas_.
En gras avec double **étoile** ou __tiret-bas__ .
Il est possible de combiner les deux **étoile et _tiret-bas_**.
Pour barrer on utilise deux tildes. ~~Barrer ça.~~
##### Liens
[Cheatsheet](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet)
##### Tables
| Tables | Are | Cool |
| ------------- |:-------------:| -----:|
| col 3 is | right-aligned | $1600 |
| col 2 is | centered | $12 |
| zebra stripes | are neat | $1 |
Markdown | Less | Pretty
--- | --- | ---
*Still* | `renders` | **nicely**
1 | 2 | 3
### Exemple pour le compte rendu
Compléter le document avec vos réponses, pour chaque consignes indiquez les commandes utilisées,le résultat et un commentaire. Par exemple :
> #### 1. Création d'un répertoire, ajout d'un fichier et lister le répertoire
> ##### Listing des commandes et résultat
user@localhost:~/$ mkdir temp
user@localhost:~/$ cd temp/
user@localhost:~/temp$ ls
user@localhost:~/temp$ touch newFile
user@localhost:~/temp$ ls
newFile
> ##### Commentaire
> Création d'un nouveau dossier **temp** dans la répertoire courant et ajout ajout d'un fichier **newFile**, nous avons utiliser la commande `ls` pour lister le contenu de ce nouveau répertoire.
## 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
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 `*`
0. Afficher la status de votre copie de travail
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é) `*`
0. Afficher l'historique de votre repo
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) `*`
0. Afficher l'historique de votre repo
0. Il ne devrait y avoir que deux entrées dans l'historique pourquoi ? `*`
0. Créer un nouveau fichier, nommé start, contenant la date et l'heure actuelle `*`
0. Créer un nouveau fichier : file2ignore
0. Afficher la status de votre copie de travail
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 `*`
0. Lister le contenu du repertoire courant, afficher le status et la log
0. Avant de commiter affichez les modifications par rapport à la précédente révision ? `*`
##### 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`)
0. Lister les branches locales et les fichiers présent dans le répertoire courant `*`
0. Aficher le status de votre repo `*`
0. Créez une branche pour _développer_ la réponse de ce point (nommez là `mybranch-2.4` par exemple)
0. Afficher un historique sous forme de graph (`a dog`) de votre repo
0. Pourquoi les 2 branches pointent elles sur la même révision ?`*`
0. Afficher à nouvea l'historique pour montrer les modifications suite au précédent commit `*`
0. Revenir la brache `mybranch`
0. Où sont passé vos reponces au point 2.4 ? `*`
0. Affichez un historique sous forme de graph (`a dog`) de votre repo, Que peux ton en dire ?
0. Revenir sur la branche master
0. Ajoutez et commitez un fichier (touch new_file)
0. Revenir sur votre branche `mybranch` pour completer le compte rendu `*`
0. Affichez un historique sous forme de graph (`a dog`) de votre repo `*`
##### 3. Merge
0. Merge depuis head
0. switcher sur une nouvelle branche `mybranch-3.1`
0. ajout un nouveau fichier nommé easy_merge avec la date et l'heure actuelle `*`
0. merger la branche `mybranch-4.1` sur `mybranch`
0. Afficher le status
0. Pourquoi n'y a t'il aucune modification en cours ? `*`
0. Affichez un historique sous forme de graph (`a dog`) de votre repo et décire l'état courant`*`
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)`*`
0. Affichez un historique sous forme de graph (`a dog`) de votre repo `*`
0. Merge avec conflit
0. Céer une nouvelle branche `mybranch-3.6`
0. Notez dans le CR la date et l'heure actuelle (avec la commande `date` par exemple) `*`
0. Switchez sur la nouvelle branche et modifiez la réponse précendante dans le CR avec le `*`
0. Réalisez le merge de la brache `mybranch-3.6` sur `mybranch`. Le prompt change, pourquoi ? Gerer le conflit et commiter.
0. Supprimer les branches de feature et afficher toutes les branches restantes, affichez un historique sous forme de graph (`a dog`) de votre repo `*`
##### 4. Remote
0. Afficher l'historique de votre repo
0. Ajouter le projet "2017-F2-Forge" comme repository distant `*`
0. Lister les branches distantes
0. Pousser votre branche de votre repo local sur le repos distant `*`
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 ?
0. Supprimer le dossier .git
0. Faire un git status ?
##### 5. Envoyer son CR
0. via une [merge request](https://docs.gitlab.com/ce/gitlab-basics/add-merge-request.html) poussez votre CR une fois celui ci terminé
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class Calculator{
Double tarif[][];
Double bornes[][];
public Calculator(){
tarif = new Double[][]{
{1.5,1.0},
{0.4,1.0},
{0.55,1.0},
{6.81,20.0},
};
bornes = new Double[][]{
{0.0,10.0},
{10.0,40.0},
{40.0,60.0},
{60.0,Double.POSITIVE_INFINITY},
};
}
Double calculate1(Double km){
if(km == null) throw new NullPointerException();
if(km < 0 ) throw new IllegalArgumentException();
Double reste = km;
Double result= 0.0;
for(int i=0;i<bornes.length;i++){
if(km >= bornes[i][0] && km < bornes[i][1]){
for(int j=0;j<i;j++){
reste-= (Double) (bornes[j][1]-bornes[j][0]);
result+= (Double)( (bornes[j][1]-bornes[j][0]) * tarif[j][0]);
}
if(i==bornes.length-1)result+=((int)(reste/tarif[i][1])*tarif[i][0]);
else result+=((Double)(reste/tarif[i][1])*tarif[i][0]);
}
}
return result;
}
Double calculate(Double km) throws NullPointerException,IllegalArgumentException{
Double reste = km;
if(km == null) throw new NullPointerException();
if(km < 0 ) throw new IllegalArgumentException();
if(km >=0 && km < 10) return (Double) (km*1.5);
else if(km >= 10 && km < 40){
reste = km - 10;
return (Double) (10*1.5+reste*0.4);
}
else if(km >= 40 && km < 60) {
reste = km - 10 - 30;
return (Double) ( 10*1.5 + 30*0.4 + reste*0.55);
}
else{
reste = km - 10 - 30 - 20;
return (Double) ( 10*1.5 + 30*0.4 + 20*0.55 + ((int)(reste/20))*6.81);
}
}
public static void main(String[] args){
Logger logger = LoggerFactory.getLogger("Calculaor");
if(args.length >= 1){
for(int i=0;i<args.length;i++){
try {
Double number = Double.parseDouble(args[i]);
Double result = new Calculator().calculate(number);
Double result2 = new Calculator().calculate1(number);
if(number == Double.POSITIVE_INFINITY) {
logger.warn("['" + args[i].subSequence(0, 4) + "...' passed] - Very long number passed");
return;
}
logger.info(number +" km => " + result + " euros");
logger.info(number +" -cakm => " + result2 + " euros");
}catch(NumberFormatException e){
logger.warn("['" + args[i] + "' passed] - You can't pass a string");
}catch(IllegalArgumentException e){
logger.warn("['" + args[i] + "' passed] - You can't pass negative km");
}catch(NullPointerException e){
logger.warn("['" + args[i] + "' passed] - You can't pass null km");
}
}
}else{
logger.error("Please provide a number");
}
}
}
# Infos étudiant : # Infos étudiant :
Par binôme Nom Prénom: Par binôme Nom Prénom:
* Nom Prénom * Reda BENCHRAA
* Nom Prénom * Youssef NIDABRAHIM
## TP 2 ## TP 2
......
import static org.junit.Assert.*;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class TestCalculator {
Logger logger = LoggerFactory.getLogger("Test");
@Test
public void testZero() {
assertEquals(0.0, new Calculator().calculate(0.0),0);
}
@Test
public void testMinus() {
try{
new Calculator().calculate(-2.4);
fail("Illegal Argument given");
}catch(IllegalArgumentException e){
logger.warn("TestMinus "+e.getClass().getName());
}
}
@Test
public void testAbove60() {
assertEquals(58.43, new Calculator().calculate(120.0),0.001);
}
@Test
public void testBelow10() {
assertEquals(13.5, new Calculator().calculate(9.0),0.001);
}
@Test
public void testBelow40() {
assertEquals(15, new Calculator().calculate(10.0),0.001);
}
@Test
public void testBelow60() {
assertEquals(27.0, new Calculator().calculate(40.0),0.001);
}
@Test
public void testNull(){
try{
new Calculator().calculate(null);
fail("Null given");
}catch(NullPointerException e){
logger.warn("TestNull "+e.getClass().getName());
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment