Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# Cours Forge ZZ2 F2 2017
# Infos étudiant :
Par binôme Nom Prénom:
* Prunier Baptiste
* Serre Clément
## 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
clserre1@A210PC12:/h/Documents/cdpw $ git init
Initialized empty Git repository in H:/Documents/cdpw/.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
clserre1@A210PC12:/h/Documents/cdpw $ git add .
clserre1@A210PC12:/h/Documents/cdpw $ git commit -m "Q1.2"
[master (root-commit) 8de1290] Q1.2
1 file changed, 158 insertions(+)
create mode 100644 cdpw_tp1.md
```
0. Afficher la status de votre copie de travail
```git
clserre1@A210PC12:/h/Documents/cdpw $ git status cdpw_tp1.md
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
clserre1@A210PC12:/h/Documents/cdpw $ git commit -am"Q1.4"
[master b73dbea] Q1.4
1 file changed, 18 insertions(+), 87 deletions(-)
```
0. Afficher l'historique de votre repo
```git
clserre1@A210PC12:/h/Documents/cdpw $ git log --all --decorate --oneline --graph
* b73dbea (HEAD -> master) Q1.4
* 7b7f60f Q1.2
```
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
clserre1@A210PC12:/h/Documents/cdpw $ mv cdpw_tp1.md cdpw_tp1_SERRE_PRUNIER.md
clserre1@A210PC12:/h/Documents/cdpw $ git commit -am"Q1.6" --amend
[master dd449ba] Q1.6
Date: Mon Jan 8 18:25:15 2018 +0100
1 file changed, 158 deletions(-)
delete mode 100644 cdpw_tp1.md
```
0. Afficher l'historique de votre repo
```git
clserre1@A210PC12:/h/Documents/cdpw $ git log --all --decorate --oneline --graph* dd449ba (HEAD -> master) Q1.6
* 7b7f60f Q1.2
```
0. Il ne devrait y avoir que deux entrées dans l'historique pourquoi ? `*`
Car le `--amend` a remplacé le dernier `commit` par le `commit` en train d'être fait.
```git
clserre1@A210PC12:/h/Documents/cdpw $ git add .
clserre1@A210PC12:/h/Documents/cdpw $ git commit -m"Q1.8"
[master b28292b] Q1.8
1 file changed, 113 insertions(+)
create mode 100644 cdpw_tp1_SERRE_PRUNIER.md
```
0. Créer un nouveau fichier, nommé start, contenant la date et l'heure actuelle `*`
```git
clserre1@A210PC12:/h/Documents/cdpw $ echo "18:35 08/01/2018" > start
clserre1@A210PC12:/h/Documents/cdpw $ git add .
clserre1@A210PC12:/h/Documents/cdpw $ git commit -m"Q1.9"
[master a49be37] Q1.9
2 files changed, 10 insertions(+)
create mode 100644 start
```
```git
clserre1@A210PC12:/h/Documents/cdpw $ touch file2ignore
```
```git
clserre1@A210PC12:/h/Documents/cdpw $ 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: cdpw_tp1_SERRE_PRUNIER.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 `*`
```git
clserre1@A210PC12:/h/Documents/cdpw $ echo "file2ignore" > .gitignore
clserre1@A210PC12:/h/Documents/cdpw $ git add .gitignore
clserre1@A210PC12:/h/Documents/cdpw $ git commit -am"Q1.12"
[master 9573e3c] Q1.12
2 files changed, 20 insertions(+), 2 deletions(-)
create mode 100644 .gitignore
```
0. Lister le contenu du repertoire courant, afficher le status et la log
```git
clserre1@A210PC12:/h/Documents/cdpw $ ls
cdpw_tp1_SERRE_PRUNIER.md file2ignore start
clserre1@A210PC12:/h/Documents/cdpw $ 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: cdpw_tp1_SERRE_PRUNIER.md
no changes added to commit (use "git add" and/or "git commit -a")
clserre1@A210PC12:/h/Documents/cdpw $ git log --all --decorate --oneline --graph
* 9573e3c (HEAD -> master) Q1.12
* 3bd908e Q1.9
* b28292b Q1.8
* dd449ba Q1.6
* 7b7f60f Q1.2
clserre1@A210PC12:/h/Documents/cdpw $
```
0. Avant de commiter affichez les modifications par rapport à la précédente révision ? `*`
```git
clserre1@A210PC12:/h/Documents/cdpw $ 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: cdpw_tp1_SERRE_PRUNIER.md
no changes added to commit (use "git add" and/or "git commit -a")
clserre1@A210PC12:/h/Documents/cdpw $ git commit -am"Q1.14"
[master ef6b3f6] Q1.14
1 file changed, 28 insertions(+)
```
##### 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
clserre1@A210PC12:/h/Documents/cdpw $ git checkout -b SERRE_PRUNIER
Switched to a new branch 'SERRE_PRUNIER'
M cdpw_tp1_SERRE_PRUNIER.md
```
0. Lister les branches locales et les fichiers présent dans le répertoire courant `*`
```git
clserre1@A210PC12:/h/Documents/cdpw $ git branch
* SERRE_PRUNIER
master
clserre1@A210PC12:/h/Documents/cdpw $ ls
cdpw_tp1_SERRE_PRUNIER.md file2ignore start
clserre1@A210PC12:/h/Documents/cdpw $ git commit -am"Q2.1"
[SERRE_PRUNIER bd03bc0] Q2.1
1 file changed, 19 insertions(+)
```
```git
clserre1@A210PC12:/h/Documents/cdpw $ git status
On branch SERRE_PRUNIER
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: cdpw_tp1_SERRE_PRUNIER.md
no changes added to commit (use "git add" and/or "git commit -a")
clserre1@A210PC12:/h/Documents/cdpw $ git commit -am"Q2.2"
[SERRE_PRUNIER a4e6b94] Q2.2
1 file changed, 10 insertions(+)
```
0. Créez une branche pour _développer_ la réponse de ce point (nommez là `mybranch-2.4` par exemple)
```git
clserre1@A210PC12:/h/Documents/cdpw $ git checkout -b "SERRE_PRUNIER-2.3"
Switched to a new branch 'SERRE_PRUNIER-2.3'
M cdpw_tp1_SERRE_PRUNIER.md
```
1. Afficher un historique sous forme de graph (`a dog`) de votre repo
```git
clserre1@A210PC12:/h/Documents/cdpw $ git log --all --decorate --oneline --graph* a4e6b94 (HEAD -> SERRE_PRUNIER-2.3, SERRE_PRUNIER) Q2.2
* bd03bc0 Q2.1
* ef6b3f6 (master) Q1.14
* 9573e3c Q1.12
* 3bd908e Q1.9
* b28292b Q1.8
* dd449ba Q1.6
* 7b7f60f Q1.2
```
2. Pourquoi les 2 branches pointent elles sur la même révision ?`*`
Les deux branches sont au même niveau de `commit`.
```git
clserre1@A210PC12:/h/Documents/cdpw $ git commit -am"Q2.3.II"
[SERRE_PRUNIER-2.3 4695520] Q2.3.II
1 file changed, 33 insertions(+), 3 deletions(-)
```
3. Afficher à nouveau l'historique pour montrer les modifications suite au précédent commit `*`
```git
clserre1@A210PC12:/h/Documents/cdpw $ git log --all --decorate --oneline --graph* 4695520 (HEAD -> SERRE_PRUNIER-2.3) Q2.3.II
* a4e6b94 (SERRE_PRUNIER) Q2.2
* bd03bc0 Q2.1
* ef6b3f6 (master) Q1.14
* 9573e3c Q1.12
* 3bd908e Q1.9
* b28292b Q1.8
* dd449ba Q1.6
* 7b7f60f Q1.2
clserre1@A210PC12:/h/Documents/cdpw $ git commit -am"Q2.3.III" [SERRE_PRUNIER-2.3 07fe6ef] Q2.3.III
1 file changed, 5 insertions(+)
```
```git
clserre1@A210PC12:/h/Documents/cdpw $ git checkout SERRE_PRUNIER
Switched to branch 'SERRE_PRUNIER'
```
0. Où sont passé vos reponces au point 2.4 ? `*`
Elles sont resté sur l'autre branche.
```git
clserre1@A210PC12:/h/Documents/cdpw $ git commit -am"Q2.5"
[SERRE_PRUNIER 08edde6] Q2.5
1 file changed, 6 insertions(+), 1 deletion(-)
```
0. Affichez un historique sous forme de graph (`a dog`) de votre repo, Que peux ton en dire ?
Il y a une branche de plus de dessiner ! (branches sur différents `commit`)
```git
clserre1@A210PC12:/h/Documents/cdpw $ git log --all --decorate --oneline --graph* 08edde6 (HEAD -> SERRE_PRUNIER) Q2.5
| * 939141b (SERRE_PRUNIER-2.3) Q2.3.III
| * 4695520 Q2.3.II
|/
* a4e6b94 Q2.2
* bd03bc0 Q2.1
* ef6b3f6 (master) Q1.14
* 9573e3c Q1.12
* 3bd908e Q1.9
* b28292b Q1.8
* dd449ba Q1.6
* 7b7f60f Q1.2
```
```git
clserre1@A210PC12:/h/Documents/cdpw $ git checkout master
Switched to branch 'master'
```
```git
clserre1@A210PC12:/h/Documents/cdpw $ touch un_fichier
clserre1@A210PC12:/h/Documents/cdpw $ git commit -am"Q2.10"
On branch master
Untracked files:
un_fichier
nothing added to commit but untracked files present
clserre1@A210PC12:/h/Documents/cdpw $ git add .
clserre1@A210PC12:/h/Documents/cdpw $ git commit -am"Q2.10" --amend
[master 9586626] Q2.10
Date: Mon Jan 8 18:45:54 2018 +0100
2 files changed, 28 insertions(+)
create mode 100644 un_fichier
```
0. Revenir sur votre branche `mybranch` pour completer le compte rendu `*`
```git
clserre1@A210PC12:/h/Documents/cdpw $ git checkout SERRE_PRUNIER
Switched to branch 'SERRE_PRUNIER'
clserre1@A210PC12:/h/Documents/cdpw $ git commit -am"Q2.12"
[SERRE_PRUNIER 6f0f3c7] Q2.12
1 file changed, 23 insertions(+)
```
0. Affichez un historique sous forme de graph (`a dog`) de votre repo `*`
```git
clserre1@A210PC12:/h/Documents/cdpw $ git log --all --decorate --oneline --graph* 665723e (HEAD -> SERRE_PRUNIER) Q2.12
* 51905a3 Q2.5
| * 9586626 (master) Q2.10
| | * 939141b (SERRE_PRUNIER-2.3) Q2.3.III
| | * 4695520 Q2.3.II
| |/
|/|
* | a4e6b94 Q2.2
* | bd03bc0 Q2.1
* | ef6b3f6 Q1.14
|/
* 9573e3c Q1.12
* 3bd908e Q1.9
* b28292b Q1.8
* dd449ba Q1.6
* 7b7f60f Q1.2
clserre1@A210PC12:/h/Documents/cdpw $ git commit -am"Q2.13"
[SERRE_PRUNIER dbc332c] Q2.13
1 file changed, 18 insertions(+)
```
```git
clserre1@A210PC12:/h/Documents/cdpw $ git checkout -b SERRE_PRUNIER-3.1
Switched to a new branch 'SERRE_PRUNIER-3.1'
M cdpw_tp1_SERRE_PRUNIER.md
```
0. ajout un nouveau fichier nommé easy_merge avec la date et l'heure actuelle `*`
```git
clserre1@A210PC12:/h/Documents/cdpw $ echo "19:09 08/01/2018" > easy_merge
clserre1@A210PC12:/h/Documents/cdpw $ git commit -am"Q3.1.II"
[SERRE_PRUNIER 1c053bd] Q3.1.II
1 file changed, 1 insertion(+)
create mode 100644 easy_merge
```
0. merger la branche `mybranch-4.1` sur `mybranch`
Nous avions fait les modifications sur SERRE_PRUNIER au lieu de SERRE_PRUNIER-3.1. Nous avons recréé un fichier sur cette dernière, d'où les `merges conflicts`.
```git
clserre1@A210PC12:/h/Documents/cdpw $ git checkout SERRE_PRUNIER
Switched to branch 'SERRE_PRUNIER'
clserre1@A210PC12:/h/Documents/cdpw $ git merge SERRE_PRUNIER-3.1
Auto-merging easy_merge
CONFLICT (add/add): Merge conflict in easy_merge
Auto-merging cdpw_tp1_SERRE_PRUNIER.md
CONFLICT (content): Merge conflict in cdpw_tp1_SERRE_PRUNIER.md
Automatic merge failed; fix conflicts and then commit the result.
```
```git
clserre1@A210PC12:/h/Documents/cdpw $ git status
On branch SERRE_PRUNIER
nothing to commit, working tree clean
```
0. Pourquoi n'y a t'il aucune modification en cours ? `*`
Car les dernières modifications de SERRE_PRUNIER-3.1 ont été mise sur SERRE_PRUNIER grace au merge.
0. Affichez un historique sous forme de graph (`a dog`) de votre repo et décire l'état courant`*`
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
```git
clserre1@A210PC12:/h/Documents/cdpw $ git log --all --decorate --oneline --graph* 4050489 (HEAD -> SERRE_PRUNIER) Q3.1.II - merge error
|\
| * 910e2ac (SERRE_PRUNIER-3.1) Q3.1.II
* | e2b7cbf Q3.1.II
* | 87d1e67 Q3.1.II
* | 40028cb Q2.13
|/
* 665723e Q2.12
* 51905a3 Q2.5
| * 9586626 (master) Q2.10
| | * 939141b (SERRE_PRUNIER-2.3) Q2.3.III
| | * 4695520 Q2.3.II
| |/
|/|
* | a4e6b94 Q2.2
* | bd03bc0 Q2.1
* | ef6b3f6 Q1.14
|/
* 9573e3c Q1.12
* 3bd908e Q1.9
* b28292b Q1.8
* dd449ba Q1.6
* 7b7f60f Q1.2
clserre1@A210PC12:/h/Documents/cdpw $ git commit -am"Q3.3"
[SERRE_PRUNIER 99fb38b] Q3.3
1 file changed, 32 insertions(+), 1 deletion(-)
```
1. Mergez les modifications de la branche `mybranch-2.4` sur `mybranch` (`*echap* :wq *enter*` pour sauvegarder le message de commit et quitter)`*`
```git
clserre1@A210PC12:/h/Documents/cdpw $ git merge SERRE_PRUNIER-2.3
Auto-merging cdpw_tp1_SERRE_PRUNIER.md
Merge made by the 'recursive' strategy.
cdpw_tp1_SERRE_PRUNIER.md | 54 ++++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 51 insertions(+), 3 deletions(-)
clserre1@A210PC12:/h/Documents/cdpw $ git commit -am"23.4.i"
[SERRE_PRUNIER 8cf25e6] 23.4.i
1 file changed, 34 insertions(+)
0. Affichez un historique sous forme de graph (`a dog`) de votre repo `*`
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
```git
clserre1@A210PC12:/h/Documents/cdpw $ git log --all --decorate --oneline --graph* 984b0f5 (HEAD -> SERRE_PRUNIER) Merge branch 'SERRE_PRUNIER-3.3' into SERRE_PRUNIER
|\
| * 939141b (SERRE_PRUNIER-2.3) Q2.3.III
| * 4695520 Q2.3.II
* | 313b711 (master/SERRE_PRUNIER) Q3.3
* | 4050489 Q3.1.II - merge error
|\ \
| * | 910e2ac (SERRE_PRUNIER-3.1) Q3.1.II
* | | e2b7cbf Q3.1.II
* | | 87d1e67 Q3.1.II
* | | 40028cb Q2.13
|/ /
* | 665723e Q2.12
* | 51905a3 Q2.5
|/
* a4e6b94 Q2.2
* bd03bc0 Q2.1
* ef6b3f6 Q1.14
| * 9586626 (master) Q2.10
|/
* 9573e3c Q1.12
* 3bd908e Q1.9
* b28292b Q1.8
* dd449ba Q1.6
* 7b7f60f Q1.2
clserre1@A210PC12:/h/Documents/cdpw $ git commit -am"23.4.ii"
[SERRE_PRUNIER 8ec6436] 23.4.ii
1 file changed, 3 insertions(+)
```git
clserre1@A210PC12:/h/Documents/cdpw $ git checkout SERRE_PRUNIER-3.6
Switched to a new branch 'SERRE_PRUNIER-3.6'
```
0. Notez dans le CR la date et l'heure actuelle (avec la commande `date` par exemple) `*`
```git
clserre1@A210PC12:/h/Documents/cdpw $ date > easy_merge
clserre1@A210PC12:/h/Documents/cdpw $ git commit -am"3.5.ii"
warning: LF will be replaced by CRLF in easy_merge.
The file will have its original line endings in your working directory.
[SERRE_PRUNIER-3.6 7bababf] 3.5.ii
Date: Mon Jan 29 18:55:53 2018 +0100
2 files changed, 13 insertions(+), 5 deletions(-)
```
0. Switchez sur la nouvelle branche et modifiez la réponse précendante dans le CR avec le `*`
```git
clserre1@A210PC12:/h/Documents/cdpw $ git checkout SERRE_PRUNIER
Switched to branch 'SERRE_PRUNIER'
Your branch is ahead of 'master/SERRE_PRUNIER' by 5 commits.
(use "git push" to publish your local commits)
clserre1@A210PC12:/h/Documents/cdpw $ date > easy_merge
```
0. Réalisez le merge de la brache `mybranch-3.6` sur `mybranch`. Le prompt change, pourquoi ? Gerer le conflit et commiter.
```git
clserre1@A210PC12:/h/Documents/cdpw $ git merge SERRE_PRUNIER-3.6
Auto-merging easy_merge
CONFLICT (content): Merge conflict in easy_merge
Automatic merge failed; fix conflicts and then commit the result.
```
Conflit de merge car les deux fichiers ont changé de contenu sur la même ligne (ici l'intégralité du fichier) après la séparation de la branche principale en deux branches.
```git
clserre1@A210PC12:/h/Documents/cdpw $ cat easy_merge
<<<<<<< HEAD
lun. 29 janv. 2018 18:59:12
=======
lun. 29 janv. 2018 18:57:17
>>>>>>> SERRE_PRUNIER-3.6
```
On garde soit l'une soit l'autre des lignes (ou les deux, ici c'est possible) et on supprime les lignes ajoutées par git.
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 ?