# Cours Forge ZZ2 F2 2017 # Infos étudiant : * SELIMOVIC Dorian ## TP 1 #### 1. Les basiques 0. Créer un repository gits ``` $ git init Initialized empty Git repository in /XXXX/2017-F2-Forge/.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 -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é) `*` > Fait. 0. Afficher l'historique de votre repo ``` $ 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%) ``` 0. Afficher l'historique de votre repo ``` $ 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 ? `*` >Parce que le commit a été ammendé 0. Créer un nouveau fichier, nommé start, contenant la date et l'heure actuelle `*` ``` $ echo `date` > 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: 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 `*` ``` $ echo file2ignore > .gitignore ``` 0. Lister le contenu du repertoire courant, afficher le status et la log ``` $ 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 ? `*` >Il affiche en vert le contenu de la question précédente. ##### 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 ``` 0. Aficher le status de votre repo `*` ``` $ 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) ``` $ git checkout -b selimovic-2.4 ``` 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 ``` 0. Revenir la brache `mybranch` ``` $ git checkout selimovic Switched to branch 'selimovic' ``` 0. Où sont passé vos reponces au point 2.4 ? `*` >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_ 0. Revenir sur la branche master ``` $ git checkout master Switched to branch 'master' ``` 0. Ajoutez et commitez un fichier (touch new_file) ``` touch new_file ``` 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 `*` ``` echo `date` > easy_merge ``` 0. merger la branche `mybranch-4.1` sur `mybranch` ``` $ 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 ``` 0. Afficher le status ``` $ git status On branch selimovic nothing to commit, working tree clean ``` 0. Pourquoi n'y a t'il aucune modification en cours ? `*` >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`*` ``` $ 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 `*` ``` * 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` ``` $ git branch selimovic-3.6 ``` 0. Notez dans le CR la date et l'heure actuelle (avec la commande `date` par exemple) `*` >Sun Feb 11 17:03:12 CET 2018 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 `*` ``` $ 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 ``` ##### 4. Remote 0. Afficher l'historique de votre repo ``` $ 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 ``` $ git ls-remote Username for 'https://gitlab.isima.fr': doselimovi Password for 'https://doselimovi@gitlab.isima.fr': From https://gitlab.isima.fr/mazenovi/2017-F2-Forge.git e9a1711f5c99e98255583ae17b019e2da3e0d6d1 HEAD 02751465467044f4da2c9acc29ce02faa0f7e07c refs/heads/BertoniWalczyszyn d8b9671f9deef99011c42d6f7920ce37422f4a6b refs/heads/BeuvotMaleterre 6fcb0bc129b241986ac09c2fc9e4513644f1f25d refs/heads/Bouhanni 946f30d6e7ab408e0b978614bb90c1cff607d374 refs/heads/CogoniHenry 0bdae066686d3c4563e93ed194626a963fe38958 refs/heads/Delefosse e34fd8946ddae8cefd2901abb45274b254713f43 refs/heads/Drosne 2f245cc73a36b33e20214a70399c8b4b80c51dad refs/heads/Falletty_Mistral 31aa94c4b144d747c8600867acc22c48d98251a7 refs/heads/JeanCharles_Neboit d838eca89340454c07deec02bb2db722f2eb3ab4 refs/heads/MosnierDrosne 1e1d462519bd372201c52be6ef4e3dca263b1652 refs/heads/PiatJullien 397c47f633438542511bd60a808c49d757388ed1 refs/heads/SERRE_PRUNIER e9a1711f5c99e98255583ae17b019e2da3e0d6d1 refs/heads/Supports 5cfaa4f0d9b78041ee1fddfedc389941eed11e27 refs/heads/TP1-CR 7f76031026bddaf1d38881c7a8fb63ec39ef9898 refs/heads/che_sig b5ccc8078858232e7913b7b9587d4c78c51d8c86 refs/heads/che_sig-2.4 e6e363caec4b50ce5e5331e7fcf65ebf88eaab9c refs/heads/develop 5cfaa4f0d9b78041ee1fddfedc389941eed11e27 refs/heads/master c3c948fdb6761dd79c143d8650f6c276dbfdde0e refs/heads/myBranch 54d210cea3f1f98e2b03af5601883282a8b4ce52 refs/heads/neboit_cournut 2c846d01b561d226555d79c37688cf3507824a06 refs/heads/reda_youssef 50cf2cb9891866475f844ce7bb89ff84987f928e refs/heads/tjo-TP1 50cf2cb9891866475f844ce7bb89ff84987f928e refs/merge-requests/1/head 397c47f633438542511bd60a808c49d757388ed1 refs/merge-requests/2/head 5cfaa4f0d9b78041ee1fddfedc389941eed11e27 refs/merge-requests/3/head 0bdae066686d3c4563e93ed194626a963fe38958 refs/merge-requests/4/head 2c846d01b561d226555d79c37688cf3507824a06 refs/merge-requests/5/head d838eca89340454c07deec02bb2db722f2eb3ab4 refs/merge-requests/6/head 54d210cea3f1f98e2b03af5601883282a8b4ce52 refs/merge-requests/7/head ``` 0. Pousser votre branche de votre repo local sur le repos distant `*` ``` $ git push origin selimovic Counting objects: 81, done. Delta compression using up to 4 threads. Compressing objects: 100% (75/75), done. Writing objects: 100% (81/81), 11.07 KiB | 0 bytes/s, done. Total 81 (delta 35), reused 0 (delta 0) remote: remote: To create a merge request for selimovic, visit: remote: https://gitlab.isima.fr/mazenovi/2017-F2-Forge/merge_requests/new?merge_request%5Bsource_branch%5D=selimovic remote: To https://gitlab.isima.fr/mazenovi/2017-F2-Forge.git * [new branch] selimovic -> selimovic ``` 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 ? >Bien que le push de toute la branche se fait en une seule fois, cela push l'ensemble des commits, avec leurs dates de création. Ainsi gitlab sait à quand remonte le dernier commit qui a modifié le fichier start (qui est bien plus ancien que le dernier commit qui a modifié le fichier du compte-rendu). 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 ``` >Cela a bien supprimé le dépôt local, il va donc falloir maintenant cloner le dépôt distant pour pouvoir commit cette dernière partie du compte-rendu...