Skip to content
Snippets Groups Projects
Forked from Vincent MAZENOD / 2017-F2-Forge
Source project has a limited visibility.

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

  1. Créer un repository git

    clserre1@A210PC12:/h/Documents/cdpw $ git init
    Initialized empty Git repository in H:/Documents/cdpw/.git/
  2. 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)

  3. Ajouter le compte rendu dans le repo *

    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
  4. Afficher la status de votre copie de travail

    clserre1@A210PC12:/h/Documents/cdpw $ git status cdpw_tp1.md
    On branch master
    nothing to commit, working tree clean
  5. 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é) *

    clserre1@A210PC12:/h/Documents/cdpw $ git commit -am"Q1.4"
    [master b73dbea] Q1.4
     1 file changed, 18 insertions(+), 87 deletions(-)
  6. Afficher l'historique de votre repo

    clserre1@A210PC12:/h/Documents/cdpw $ git log --all --decorate --oneline --graph
    * b73dbea (HEAD -> master) Q1.4
    * 7b7f60f Q1.2
  7. 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) *

    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
  8. Afficher l'historique de votre repo

    clserre1@A210PC12:/h/Documents/cdpw $ git log --all --decorate --oneline --graph* dd449ba (HEAD -> master) Q1.6
    * 7b7f60f Q1.2
  9. 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.

    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
  10. Créer un nouveau fichier, nommé start, contenant la date et l'heure actuelle *

    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
  11. Créer un nouveau fichier : file2ignore

    clserre1@A210PC12:/h/Documents/cdpw $ touch file2ignore
  12. Afficher la status de votre copie de travail

    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")
  13. On souhaite que ce fichier soit ignoré et ne soit jamais commiter. Réalisez la configuration nécesaire pour que cette regle soit effective *

    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
  14. Lister le contenu du repertoire courant, afficher le status et la log

    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 $
  15. Avant de commiter affichez les modifications par rapport à la précédente révision ? *

    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
  1. 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)
    clserre1@A210PC12:/h/Documents/cdpw $ git checkout -b SERRE_PRUNIER
    Switched to a new branch 'SERRE_PRUNIER'
    M       cdpw_tp1_SERRE_PRUNIER.md
  2. Lister les branches locales et les fichiers présent dans le répertoire courant *
    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(+)
  3. Aficher le status de votre repo *
    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(+)
  4. Créez une branche pour développer la réponse de ce point (nommez là mybranch-2.4 par exemple)
    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
    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
    1. Pourquoi les 2 branches pointent elles sur la même révision ?*
      Les deux branches sont au même niveau de commit.
    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(-)
    1. Afficher à nouveau l'historique pour montrer les modifications suite au précédent commit *
    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(+)
  5. Revenir la brache mybranch
  6. Où sont passé vos reponces au point 2.4 ? *
  7. Affichez un historique sous forme de graph (a dog) de votre repo, Que peux ton en dire ?
  8. Revenir sur la branche master
  9. Ajoutez et commitez un fichier (touch new_file)
  10. Revenir sur votre branche mybranch pour completer le compte rendu *
  11. Affichez un historique sous forme de graph (a dog) de votre repo *
3. Merge
  1. Merge depuis head
  2. switcher sur une nouvelle branche mybranch-3.1
  3. ajout un nouveau fichier nommé easy_merge avec la date et l'heure actuelle *
  4. merger la branche mybranch-4.1 sur mybranch
  5. Afficher le status
  6. Pourquoi n'y a t'il aucune modification en cours ? *
  7. Affichez un historique sous forme de graph (a dog) de votre repo et décire l'état courant*
  8. Merge avec modifications
  9. Mergez les modifications de la branche mybranch-2.4 sur mybranch (*echap* :wq *enter* pour sauvegarder le message de commit et quitter)*
  10. Affichez un historique sous forme de graph (a dog) de votre repo *
  11. Merge avec conflit
  12. Céer une nouvelle branche mybranch-3.6
  13. Notez dans le CR la date et l'heure actuelle (avec la commande date par exemple) *
  14. Switchez sur la nouvelle branche et modifiez la réponse précendante dans le CR avec le *
  15. Réalisez le merge de la brache mybranch-3.6 sur mybranch. Le prompt change, pourquoi ? Gerer le conflit et commiter.
  16. 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
  1. Afficher l'historique de votre repo
  2. Ajouter le projet "2017-F2-Forge" comme repository distant *
  3. Lister les branches distantes
  4. Pousser votre branche de votre repo local sur le repos distant *
  5. 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 ?
  6. Supprimer le dossier .git
  7. Faire un git status ?