Newer
Older
# Cours Forge ZZ2 F2 2017
# Infos étudiant :
* SELIMOVIC Dorian
## TP 1
#### 1. Les basiques
0. Créer un repository gits
```
$ git init
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 -A
$ git commit -m "Add compte-rendu.md"
[master (root-commit) 6bd3cbb] Add compte-rendu.md
1 file changed, 14 insertions(+)
create mode 100644 compte-rendu.md
```
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: compte-rendu.md
no changes added to commit (use "git add" and/or "git commit -a")
```
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 log
commit e4e58b98b1b008bb0a5000ecfc47c4393d03907d
Author: Dorian Selimovic <selimovic.dorian@gmail.com>
Date: Mon Feb 5 18:49:21 2018 +0100
Q1.5
commit f256d85c1c2f27e7e563b458b7093e896ca61ddd
Author: Dorian Selimovic <selimovic.dorian@gmail.com>
Date: Mon Feb 5 18:47:10 2018 +0100
Q1.3
commit 6bd3cbb92961dcc7cc2887392ba991ddffee4632
Author: Dorian Selimovic <selimovic.dorian@gmail.com>
Date: Mon Feb 5 18:44:36 2018 +0100
Add compte-rendu.md
```
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) `*`
```
$ mv compte-rendu.md selimovic-compte-rendu.md
$ git add -A
$ git commit -am "Rename compte-rendu"
[master 80d9397] Rename compte-rendu
1 file changed, 21 insertions(+)
rename compte-rendu.md => selimovic-compte-rendu.md (89%)
```
```
$ git log
commit 80d939781c8f3b5b501b8461c6dd998245e338dd
Author: Dorian Selimovic <selimovic.dorian@gmail.com>
Date: Mon Feb 5 18:51:55 2018 +0100
Rename compte-rendu
commit e4e58b98b1b008bb0a5000ecfc47c4393d03907d
Author: Dorian Selimovic <selimovic.dorian@gmail.com>
Date: Mon Feb 5 18:49:21 2018 +0100
Q1.5
commit f256d85c1c2f27e7e563b458b7093e896ca61ddd
Author: Dorian Selimovic <selimovic.dorian@gmail.com>
Date: Mon Feb 5 18:47:10 2018 +0100
Q1.3
commit 6bd3cbb92961dcc7cc2887392ba991ddffee4632
Author: Dorian Selimovic <selimovic.dorian@gmail.com>
Date: Mon Feb 5 18:44:36 2018 +0100
Add compte-rendu.md
```
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 `*`
```
$ 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: selimovic-compte-rendu.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 `*`
0. Lister le contenu du repertoire courant, afficher le status et la log
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
```
$ ls -la
total 28
drwxr-xr-x 3 XXXX XXXX 4096 Feb 5 18:57 .
drwxr-xr-x 3 XXXX XXXX 4096 Feb 5 18:39 ..
-rw-r--r-- 1 XXXX XXXX 0 Feb 5 18:56 file2ignore
drwxr-xr-x 8 XXXX XXXX 4096 Feb 5 18:58 .git
-rw-r--r-- 1 XXXX XXXX 12 Feb 5 18:57 .gitignore
-rw-r--r-- 1 XXXX XXXX 6904 Feb 5 18:58 selimovic-compte-rendu.md
-rw-r--r-- 1 XXXX XXXX 28 Feb 5 18:55 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: selimovic-compte-rendu.md
no changes added to commit (use "git add" and/or "git commit -a")
$ git log
commit 02672f8fd9d27dd80c7f5201fa715f0c3b78911a
Author: Dorian Selimovic <selimovic.dorian@gmail.com>
Date: Mon Feb 5 18:58:06 2018 +0100
Q1.13
commit 696e5f9ccf8b6b4ac0af9902c612bf51f2690a91
Author: Dorian Selimovic <selimovic.dorian@gmail.com>
Date: Mon Feb 5 18:56:28 2018 +0100
Q1.10
commit db1ca34d13f87563424855a79e09d07494d4d511
Author: Dorian Selimovic <selimovic.dorian@gmail.com>
Date: Mon Feb 5 18:54:13 2018 +0100
Q1.9
commit 80d939781c8f3b5b501b8461c6dd998245e338dd
Author: Dorian Selimovic <selimovic.dorian@gmail.com>
Date: Mon Feb 5 18:51:55 2018 +0100
Rename compte-rendu
commit e4e58b98b1b008bb0a5000ecfc47c4393d03907d
Author: Dorian Selimovic <selimovic.dorian@gmail.com>
Date: Mon Feb 5 18:49:21 2018 +0100
Q1.5
commit f256d85c1c2f27e7e563b458b7093e896ca61ddd
Author: Dorian Selimovic <selimovic.dorian@gmail.com>
Date: Mon Feb 5 18:47:10 2018 +0100
Q1.3
```
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`)
```
$ git checkout -b selimovic
Switched to a new branch 'selimovic'
```
0. Lister les branches locales et les fichiers présent dans le répertoire courant `*`
```
$ git branch
master
* selimovic
$ ls -la
total 32
drwxr-xr-x 3 XXXX XXXX 4096 Feb 5 18:57 .
drwxr-xr-x 3 XXXX XXXX 4096 Feb 5 18:39 ..
-rw-r--r-- 1 XXXX XXXX 0 Feb 5 18:56 file2ignore
drwxr-xr-x 8 XXXX XXXX 4096 Feb 5 19:03 .git
-rw-r--r-- 1 XXXX XXXX 12 Feb 5 18:57 .gitignore
-rw-r--r-- 1 XXXX XXXX 8743 Feb 5 19:01 selimovic-compte-rendu.md
-rw-r--r-- 1 XXXX XXXX 28 Feb 5 18:55 start
```
```
$ git status
On branch selimovic
nothing to commit, working tree clean
```
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
```
$ git log --all --decorate --oneline --graph
* 434403c (HEAD -> selimovic-2.4, selimovic) Q2.3
* 992376b Q2.2
* 7a07334 (master) Q1.15
* 02672f8 Q1.13
* 696e5f9 Q1.10
* db1ca34 Q1.9
* 80d9397 Rename compte-rendu
* e4e58b9 Q1.5
* f256d85 Q1.3
* 6bd3cbb Add compte-rendu.md
```
0. Pourquoi les 2 branches pointent elles sur la même révision ?`*`
>Parce qu'il n'y a pas encore de commit supplémentaire sur la branche selimovic-2.4
0. Afficher à nouvea l'historique pour montrer les modifications suite au précédent commit `*`
```
$ git log --all --decorate --oneline --graph
* 77e2569 (HEAD -> selimovic-2.4) Q2.4.2
* 434403c (selimovic) Q2.3
* 992376b Q2.2
* 7a07334 (master) Q1.15
* 02672f8 Q1.13
* 696e5f9 Q1.10
* db1ca34 Q1.9
* 80d9397 Rename compte-rendu
* e4e58b9 Q1.5
* f256d85 Q1.3
* 6bd3cbb Add compte-rendu.md
```
```
$ git checkout selimovic
Switched to branch 'selimovic'
```
>Elles sont 'restées' sur la branche selimovic-2.4 car les commits ont été réalisés sur cette branche là.
0. Affichez un historique sous forme de graph (`a dog`) de votre repo, Que peux ton en dire ?
```
$ git log --all --decorate --oneline --graph
* 9b99cb6 (HEAD -> selimovic) Q2.6
| * ae470aa (selimovic-2.4) Q2.4.3
| * 77e2569 Q2.4.2
|/
* 434403c Q2.3
* 992376b Q2.2
* 7a07334 (master) Q1.15
* 02672f8 Q1.13
* 696e5f9 Q1.10
* db1ca34 Q1.9
* 80d9397 Rename compte-rendu
* e4e58b9 Q1.5
* f256d85 Q1.3
* 6bd3cbb Add compte-rendu.md
```
>On a un _embranchement_ de deux branches qui _avancent séparément_
```
$ git checkout master
Switched to branch 'master'
```
0. Revenir sur votre branche `mybranch` pour completer le compte rendu `*`
```
$ git checkout selimovic
Switched to branch 'selimovic'
```
0. Affichez un historique sous forme de graph (`a dog`) de votre repo `*`
```
$ git log --all --decorate --oneline --graph
* 4b3e42e (HEAD -> selimovic) Q2.10
* b41b6f3 Q2.7
* 9b99cb6 Q2.6
| * 3ed4f76 (master) Add new_file
| | * ae470aa (selimovic-2.4) Q2.4.3
| | * 77e2569 Q2.4.2
| |/
|/|
* | 434403c Q2.3
* | 992376b Q2.2
|/
* 7a07334 Q1.15
* 02672f8 Q1.13
* 696e5f9 Q1.10
* db1ca34 Q1.9
* 80d9397 Rename compte-rendu
* e4e58b9 Q1.5
* f256d85 Q1.3
* 6bd3cbb Add compte-rendu.md
```
##### 3. Merge
0. Merge depuis head
0. switcher sur une nouvelle branche `mybranch-3.1`
```
$ git checkout -b selimovic-3.1
Switched to a new branch 'selimovic-3.1'
```
0. ajout un nouveau fichier nommé easy_merge avec la date et l'heure actuelle `*`
```
$ git checkout selimovic
Switched to branch 'selimovic'
$ git merge selimovic-3.1
Updating 6ff966f..0d8fcb8
Fast-forward
easy_merge | 1 +
selimovic-compte-rendu.md | 9 +++++++++
2 files changed, 10 insertions(+)
create mode 100644 easy_merge
```
```
$ git status
On branch selimovic
nothing to commit, working tree clean
```
>Parce qu'on a merge selimovic-3.1 dans selimovic, les deux branches sont au même niveau
0. Affichez un historique sous forme de graph (`a dog`) de votre repo et décire l'état courant`*`
375
376
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
403
404
405
406
407
408
409
410
411
412
413
```
$ git log --all --decorate --oneline --graph
* 1a2af7c (HEAD -> selimovic) Q3.3
* 0d8fcb8 (selimovic-3.1) Q3.1.2
* 6ff966f Q2.11
* 4b3e42e Q2.10
* b41b6f3 Q2.7
* 9b99cb6 Q2.6
| * 3ed4f76 (master) Add new_file
| | * ae470aa (selimovic-2.4) Q2.4.3
| | * 77e2569 Q2.4.2
| |/
|/|
* | 434403c Q2.3
* | 992376b Q2.2
|/
* 7a07334 Q1.15
* 02672f8 Q1.13
* 696e5f9 Q1.10
* db1ca34 Q1.9
* 80d9397 Rename compte-rendu
* e4e58b9 Q1.5
* f256d85 Q1.3
* 6bd3cbb Add compte-rendu.md
```
>On a un arbre de ce type
```
|
v
|
+- selimovic-2.4
|
+- master
|
+- selimovic-3.1
|
+- selimovic
```
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 selimovic-2.4
Auto-merging selimovic-compte-rendu.md
Merge made by the 'recursive' strategy.
selimovic-compte-rendu.md | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
```
0. Affichez un historique sous forme de graph (`a dog`) de votre repo `*`
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
```
* 1032a2f (HEAD -> selimovic) Merge branch 'selimovic-2.4' into selimovic
|\
| * ae470aa (selimovic-2.4) Q2.4.3
| * 77e2569 Q2.4.2
* | 2fadf41 Q3.4
* | 1a2af7c Q3.3
* | 0d8fcb8 (selimovic-3.1) Q3.1.2
* | 6ff966f Q2.11
* | 4b3e42e Q2.10
* | b41b6f3 Q2.7
* | 9b99cb6 Q2.6
|/
* 434403c Q2.3
* 992376b Q2.2
| * 3ed4f76 (master) Add new_file
|/
* 7a07334 Q1.15
* 02672f8 Q1.13
* 696e5f9 Q1.10
* db1ca34 Q1.9
* 80d9397 Rename compte-rendu
* e4e58b9 Q1.5
* f256d85 Q1.3
* 6bd3cbb Add compte-rendu.md
```
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 `*`
```
$ git checkout selimovic-3.6
Switched to branch 'selimovic-3.6'
```
0. Réalisez le merge de la brache `mybranch-3.6` sur `mybranch`. Le prompt change, pourquoi ? Gerer le conflit et commiter.
```
$ git checkout selimovic
Switched to branch 'selimovic'
$ git merge selimovic-3.6
Auto-merging selimovic-compte-rendu.md
CONFLICT (content): Merge conflict in selimovic-compte-rendu.md
Automatic merge failed; fix conflicts and then commit the result.
$ git add -A
$ git commit -m "Solve conflict while merging selimovic-3.6 into selimovic"
[selimovic 677502e] Solve conflict while merging selimovic-3.6 into selimovic
```
0. Supprimer les branches de feature et afficher toutes les branches restantes, affichez un historique sous forme de graph (`a dog`) de votre repo `*`
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
```
$ git branch -d selimovic-2.4
Deleted branch selimovic-2.4 (was ae470aa).
$ git branch -d selimovic-3.1
Deleted branch selimovic-3.1 (was 0d8fcb8).
$ git branch -d selimovic-3.6
Deleted branch selimovic-3.6 (was 4e7f0e3).
$ git log --all --decorate --oneline --graph
* 677502e (HEAD -> selimovic) Solve conflict while merging selimovic-3.6 into selimovic
|\
| * 4e7f0e3 Q3.6.3
* | 704d8d6 Q3.6.2
|/
* bec7f38 Q3.5.2
* 1032a2f Merge branch 'selimovic-2.4' into selimovic
|\
| * ae470aa Q2.4.3
| * 77e2569 Q2.4.2
* | 2fadf41 Q3.4
* | 1a2af7c Q3.3
* | 0d8fcb8 Q3.1.2
* | 6ff966f Q2.11
* | 4b3e42e Q2.10
* | b41b6f3 Q2.7
* | 9b99cb6 Q2.6
|/
* 434403c Q2.3
* 992376b Q2.2
| * 3ed4f76 (master) Add new_file
|/
* 7a07334 Q1.15
* 02672f8 Q1.13
* 696e5f9 Q1.10
* db1ca34 Q1.9
* 80d9397 Rename compte-rendu
* e4e58b9 Q1.5
* f256d85 Q1.3
* 6bd3cbb Add compte-rendu.md
```
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
```
$ git log --oneline
4b78aee Q3.7
677502e Solve conflict while merging selimovic-3.6 into selimovic
4e7f0e3 Q3.6.3
704d8d6 Q3.6.2
bec7f38 Q3.5.2
1032a2f Merge branch 'selimovic-2.4' into selimovic
2fadf41 Q3.4
1a2af7c Q3.3
0d8fcb8 Q3.1.2
6ff966f Q2.11
4b3e42e Q2.10
b41b6f3 Q2.7
9b99cb6 Q2.6
ae470aa Q2.4.3
77e2569 Q2.4.2
434403c Q2.3
992376b Q2.2
7a07334 Q1.15
02672f8 Q1.13
696e5f9 Q1.10
db1ca34 Q1.9
80d9397 Rename compte-rendu
e4e58b9 Q1.5
f256d85 Q1.3
6bd3cbb Add compte-rendu.md
```
0. Ajouter le projet "2017-F2-Forge" comme repository distant `*`
```
$ git remote add origin https://gitlab.isima.fr/mazenovi/2017-F2-Forge.git
```
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 ?