-
Clement SERRE authoredClement SERRE authored
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
-
Créer un repository git
clserre1@A210PC12:/h/Documents/cdpw $ git init Initialized empty Git repository in H:/Documents/cdpw/.git/
-
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) -
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
-
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
-
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(-)
-
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
-
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
-
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
-
Il ne devrait y avoir que deux entrées dans l'historique pourquoi ?
*
Car le
--amend
a remplacé le derniercommit
par lecommit
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
-
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
-
Créer un nouveau fichier : file2ignore
clserre1@A210PC12:/h/Documents/cdpw $ touch file2ignore
-
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")
-
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
-
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 $
-
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
- 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
- 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(+)
- 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(+)
- 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
- 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
- Pourquoi les 2 branches pointent elles sur la même révision ?
*
Les deux branches sont au même niveau decommit
.
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(-)
- 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(+)
- Afficher un historique sous forme de graph (
- Revenir la brache
mybranch
- Où sont passé vos reponces au point 2.4 ?
*
- Affichez un historique sous forme de graph (
a dog
) de votre repo, Que peux ton en dire ? - Revenir sur la branche master
- Ajoutez et commitez un fichier (touch new_file)
- Revenir sur votre branche
mybranch
pour completer le compte rendu*
- Affichez un historique sous forme de graph (
a dog
) de votre repo*
3. Merge
- Merge depuis head
- switcher sur une nouvelle branche
mybranch-3.1
- ajout un nouveau fichier nommé easy_merge avec la date et l'heure actuelle
*
- merger la branche
mybranch-4.1
surmybranch
- Afficher le status
- Pourquoi n'y a t'il aucune modification en cours ?
*
- Affichez un historique sous forme de graph (
a dog
) de votre repo et décire l'état courant*
- Merge avec modifications
- Mergez les modifications de la branche
mybranch-2.4
surmybranch
(*echap* :wq *enter*
pour sauvegarder le message de commit et quitter)*
- Affichez un historique sous forme de graph (
a dog
) de votre repo*
- Merge avec conflit
- Céer une nouvelle branche
mybranch-3.6
- Notez dans le CR la date et l'heure actuelle (avec la commande
date
par exemple)*
- Switchez sur la nouvelle branche et modifiez la réponse précendante dans le CR avec le
*
- Réalisez le merge de la brache
mybranch-3.6
surmybranch
. Le prompt change, pourquoi ? Gerer le conflit et commiter. - 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
- Afficher l'historique de votre repo
- Ajouter le projet "2017-F2-Forge" comme repository distant
*
- Lister les branches distantes
- Pousser votre branche de votre repo local sur le repos distant
*
- 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 ?
- Supprimer le dossier .git
- Faire un git status ?