-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpresentation.tex
More file actions
1493 lines (1225 loc) · 45.2 KB
/
presentation.tex
File metadata and controls
1493 lines (1225 loc) · 45.2 KB
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
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
364
365
366
367
368
369
370
371
372
373
374
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
414
415
416
417
418
419
420
421
422
423
424
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
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
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
520
521
522
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
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
\documentclass[a4paper,11pt]{beamer}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage{caption}
\usepackage{subcaption}
% Thème Darmstadt
\usetheme{Darmstadt}
\usepackage{graphicx}
\usepackage{caption}
\usepackage{ragged2e}
\usepackage{listings}
\usepackage{color}
\usepackage{gitdags}
\usepackage{fontawesome, wasysym}
%\captionsetup[figure]{labelformat=empty}
\setbeamertemplate{navigation symbols}{}
\setbeamertemplate{footline}
{
\begin{beamercolorbox}[ht=2.5ex,dp=1.125ex,%
leftskip=.3cm,rightskip=.3cm plus1fil]{title in head/foot}%
{\usebeamerfont{title in head/foot}\insertshorttitle} \hfill
\insertframenumber / \inserttotalframenumber%
\end{beamercolorbox}%
% \begin{beamercolorbox}[colsep=1.5pt]{lower separation line foot}
% \end{beamercolorbox}
}
% Informations sur la présentation
\title{Gestion de code avec Git (FIEC30EM)}
\author{frank.buloup@univ-amu.fr}
\institute{Aix Marseille Université\\Faculté des Sciences du Sport\\Master 2 IEAP - Facteurs Humains}
\date{}
\newcounter{exampleBlockCounter}
\setcounter{exampleBlockCounter}{1}
\definecolor{comment}{rgb}{0.12, 0.38, 0.18 } %adjusted, in Eclipse: {0.25, 0.42, 0.30 } = #3F6A4D
\definecolor{keyword}{rgb}{0.37, 0.08, 0.25} % #5F1441
\definecolor{string}{rgb}{0.06, 0.10, 0.98} %
\lstset{
language=Python,
frame=single,
frameround=tttt,
rulesepcolor=\color{black},
showspaces=false,showtabs=false,tabsize=2,
numberstyle=\tiny,numbers=left,
stringstyle=\color{string},
keywordstyle = \color{keyword}\bfseries,
commentstyle=\color{comment}\itshape,
basicstyle=\ttfamily\footnotesize,
breaklines=true,
captionpos=b
}
%\includeonlyframes{current}
\begin{document}
% Première diapositive : Titre
\begin{frame}[plain]
\titlepage
\center{\includegraphics[scale=0.75]{images/by-nc-sa.eps}}
\vspace{0.5cm}
\includegraphics[scale=0.6]{images/LogoAMU.png}\hspace*{2cm}
\includegraphics[scale=0.35]{images/LogoCNRS.eps}\hspace*{2cm}
\includegraphics[scale=0.09]{images/LogoISM.eps}
\end{frame}
\begin{frame}{Gestion de code avec Git}
\tableofcontents[hideallsubsections]
\end{frame}
\AtBeginSection{%
\begin{frame}
\tableofcontents[sections=\value{section}]
\end{frame}
}
\section{Introduction}
\subsection{Objectifs du module \& Organisation}
\begin{frame}
\center
À l'issue de cette formation, vous serez capable de :
\vspace{0.25cm}
\begin{enumerate}
\item Mettre en œuvre une petite plateforme d'acquisition de données
\begin{enumerate}
\item Utiliser Arduino IDE et un Uno R4 pour l'acquisition des données
\item Utiliser Python pour créer un gestionnaire d'essai
\item Utiliser Python pour le traitement des données
\end{enumerate}
\item Mettre en œuvre un projet en mode collaboratif avec Git sur GitHub
\begin{enumerate}
\item Décrire les principes de fonctionnement d'un gestionnaire de versions distribué
\item Créer, initialiser et cloner un dépôt avec Git
\item Manipuler les commandes de Git pour gérer les fichiers et les branches
\item Résoudre les conflits de fusion
\end{enumerate}
\end{enumerate}
\end{frame}
\begin{frame}
\begin{block}{Organisation}
\begin{itemize}
\item Un projet par équipe pour mettre en œuvre ces apprentissages
\item Cours et TDs pour apprendre les bases de Git
\item Deux (à trois) étudiants par équipe
\end{itemize}
\end{block}
\begin{block}{Volumes horaires}
\begin{itemize}
\item Environ 14 heures pour le projet
\item Environ 4 heures de cours/TDs
% \item Environ 2 heures pour l'oral de présentation du projet
\end{itemize}
\end{block}
\begin{alertblock}{Evaluation}
\begin{itemize}
\item 50\% sur un CC Git (examen écrit 30mn)
\item 50\% sur le projet tout au long du module
%\item 50\% sur une présentation orale du projet par équipe
% \begin{itemize}
% \item 10mn de présentation
% \item 5mn de questions
% \item Grille d'évaluation
% \end{itemize}
\end{itemize}
\end{alertblock}
\end{frame}
\subsection{les projets \& Les comptes GitHub}
\begin{frame}
\begin{block}{Les projets}
Sur la base d'un Arduino Uno R4 Wifi avec :
\begin{itemize}
\item une jauge de contrainte (2 postes)
\item une résistance à détection de force (2 postes)
\item un capteur à ultrason (2 postes)
\item \textcolor{red}{un potentiomètre}
\item \textcolor{red}{un codeur optique}
\end{itemize}
\end{block}
\begin{block}{Comptes GitHub}
\begin{itemize}
\item Création de comptes sur GitHub
\item Compte du Master : MasterFHGit
\end{itemize}
\end{block}
\end{frame}
\subsection{Les projets : c'est parti dès maintenant !}
\begin{frame}
\begin{block}{Les projets - Répartition par binômes voire trinômes}
Sur la base d'un Arduino Uno R4 Wifi avec :
\begin{itemize}
\item une jauge de contrainte (2 postes - 2x2 étudiants)
\item une résistance à détection de force (2 postes - 2x2 étudiants)
\item un capteur à ultrason (2 postes - 2x2 étudiants)
\item \textcolor{red}{un potentiomètre - 2 étudiants}
\item \textcolor{red}{un codeur optique - 2 étudiants}
\end{itemize}
\end{block}
\centering
\normalsize
\textcolor{blue}{\textbf{\underline{\href{https://raw.githubusercontent.com/fbuloup/CodeManagementWithGit/main/projets.pdf}{Veuillez suivre ce lien pour démarrer le projet dès maintenant}}}}
\end{frame}
\section{Présentation, Utilisation \& Installation de Git}
\subsection{Git ? C'est quoi ?}
\begin{frame}
\begin{block}{Git ? C'est quoi ?}
\centering
\includegraphics[scale=0.1]{images/git.png}
\end{block}
\centering
\huge \textbf{Une idée ?}
\normalsize
\textcolor{blue}{\textbf{\underline{\href{https://git-scm.com}{Documentation Git}}}}
\end{frame}
\begin{frame}
\begin{block}{Git n'est pas un serveur (au sens centralisé)}
\begin{itemize}
\item Git n'offre pas de fonctionnalité de gestion de projet complète (e.g. gestion de tâches, de bugs ou wiki)
\item Github et GitLab sont deux exemples de solutions complètes
\end{itemize}
\centering
\begin{tabular}{c c c c}
\includegraphics[scale=0.1]{images/github.png} & \includegraphics[scale=0.066]{images/gitlab.png} & \includegraphics[scale=0.08]{images/bitbucket.png} & \includegraphics[scale=0.045]{images/gitea.png} \\
\textbf{Github} & \textbf{GitLab} & \textbf{Bitbucket} & \textbf{Gitea}
\end{tabular}
\end{block}
\pause
\begin{block}{Git n'est pas un espace de stockage de fichiers type Dropbox}
\begin{itemize}
\item Pas de sauvegarde automatique des fichiers
\item Pas de gestion optimale des fichiers volumineux$^*$ ou binaires$^{**}$
\end{itemize}
\end{block}
\vspace{.125cm}
\centering
\footnotesize $^{*}$Dans ce cas, on peut utiliser une extension spécifique : git LFS\\
\footnotesize $^{**}$Les fichiers binaires ne sont pas très lisibles (git diff !!!)
\end{frame}
\begin{frame}
\begin{block}{Git est un système de contrôle de version (Version Control System)}
\begin{itemize}
\item Historique des versions de tous les fichiers
\item Manipulation complète de l'historique possible
\item Décentralisé (bientôt plus clair...)
\item On trouve aussi : "Source Code Management System"
\end{itemize}
\end{block}
\pause
\begin{block}{Pourquoi gérer des versions de fichiers, utiliser un VCS ?}
\begin{itemize}
\item Pour pouvoir revenir en arrière
\item Pour comparer des versions de fichiers
\item Pour expérimenter, tester des idées
\item Pour travailler à plusieurs plus facilement
\end{itemize}
\end{block}
\end{frame}
\begin{frame}
\centering {\huge \textbf{\textcolor{red}{Vous pouvez gérer tous types de fichiers avec git !}}}
\begin{block}{Exemples de fichiers gérés par git}
\begin{itemize}
\item Fichiers de code informatique
\item Fichiers textes (e.g. .doc)
\item Fichiers binaires (e.g. images, sons) - Si volumineux : git LFS$^{*}$
\item Fichiers de données - Si volumineux : git LFS$^{*}$
\item Documentation de projets (cahier des charges, devis...)
\item etc.
\end{itemize}
\end{block}
\vspace{.25cm}
\centering {\huge \textbf{\textcolor{red}{Gestion collaborative de projets}}}
\vspace{.25cm}
\footnotesize $^{*}$Utilisation de l'extension \textcolor{blue}{\textbf{\underline{\href{https://git-lfs.com/}{Git Large File Storage}}}}\\
Taille max. de 5GB sur Github (AWS Amazon S3)
\end{frame}
\subsection{Petit historique des systèmes de contrôle de versions}
\begin{frame}
\centering {\huge \textbf{\textcolor{red}{Un peu d'histoire !}}}
\begin{block}{Local VCS - Avant... il y a longtemps !}
\begin{itemize}
\item Système D : horodatage, classement dossiers, compression etc.
\item Pro : Revision Control System (1982, projet GNU$^{*}$)
\end{itemize}
\centering
\includegraphics[scale=0.55]{images/SaveLocalNew.png}
\end{block}
\centering
\footnotesize $^{*}$GNU : GNU's Not Unix
\end{frame}
\begin{frame}
\begin{block}{Centralized VCS - Avant... un peux moins longtemps !}
\begin{itemize}
\item Partage plus facile
\item Connexion réseau obligatoire (approche Client-Serveur)
\end{itemize}
\centering
\includegraphics[scale=0.35]{images/SaveCentralNew.png}
\end{block}
\centering
\footnotesize e.g. Concurrent Version System (CVS), Subversion (SVN)
\end{frame}
\begin{frame}
\begin{block}{Distributed VCS - Maintenant, depuis un moment (début 2000) !}
\begin{itemize}
\item État "serveur" et réseau pas critique (approche Pair-à-Pair)
\item On peut remonter un "serveur" à partir des autres machines
\item Les opérations locales (la majorité) sont rapides
\item Travail privé possible
\end{itemize}
\centering
\includegraphics[scale=0.25]{images/SaveDistribNew.png}
\end{block}
\centering
\footnotesize e.g. Git, Mercurial, Darcs
\end{frame}
\begin{frame}
\begin{block}{L'origine de Git}
\begin{itemize}
\item Créé en 2005 par \textcolor{blue}{\textbf{\underline{\href{https://fr.wikipedia.org/wiki/Linus_Torvalds}{Linus TORVALDS}}}}
\item Pour le noyau Linux
\item Activement maintenu par \textcolor{blue}{\textbf{\underline{\href{https://simple.wikipedia.org/wiki/Junio_Hamano}{Junio HAMANO}}}}
\item Popularisé par GitHub
\item On prononce "guit" et pas "jit" !
\item Git = Crétin (= Conna... !)
\end{itemize}
\end{block}
\centering
\textcolor{blue}{\textbf{\underline{\href{https://fr.wikipedia.org/wiki/Git}{Git - Wikipedia}}}}
\end{frame}
\begin{frame}
\begin{block}{Les principales caractéristiques de Git}
\begin{itemize}
\item Contrôle de version distribué (pair-à-pair)
\item Gestion des branches de code (création, suppression, fusion)
\item Opérations atomiques (Commits)
\item Données de gestion stockée dans un répertoire .git
\end{itemize}
\end{block}
\end{frame}
\subsection{Les différents modes d'utilisation}
\begin{frame}
\begin{block}{Comment utiliser Git ?}
\begin{itemize}
\item En ligne de commande (Terminal \& Git Bash pour Windows)
\item Outils graphiques intégrés à Git : "git-gui" et "gitk"
\item Avec une IHM dans un OS (GitKraken, SourceTree) : \textcolor{blue}{\textbf{\underline{\href{https://git-scm.com/downloads/guis}{ici}}}}
\item Intégré dans un EDI (plugin, package etc.)
\item Sur internet : github, gitlab, bitbucket etc.
\end{itemize}
\centering
\includegraphics[scale=0.1]{images/gitkrkaen.png}
\includegraphics[scale=0.25]{images/sourcetree.jpg}
\end{block}
\centering
\textcolor{red}{\textbf{L'apprentissage en ligne de commande est le plus efficace !}}
\end{frame}
\subsection{Utilisation sur GitHub}
\begin{frame}
\begin{exampleblock}{Exercice \Roman{exampleBlockCounter} - Premier pas avec GitHub}
\begin{enumerate}
\item Créer un compte sur GitHub
\item Créer un premier dépôt public dans GitHub nommé "FirstRepository"
\end{enumerate}
\center{
\includegraphics[scale=0.3]{images/CreateRepo.PNG}
\captionof{figure}{Création d'un dépôt dans Github}}
\end{exampleblock}
\end{frame}
\begin{frame}
\center{
\includegraphics[scale=0.25]{images/firstRepository-2.png}}
\captionof{figure}{Création du dépôt "FirstRepository" public avec fichier README}
\end{frame}
\begin{frame}
\begin{block}{État initial après le premier commit sur GitHub}
\centering
\begin{tikzpicture}
\gitDAG[grow right sep = 2em]{2d6c035};
\gitremotebranch
[main] % node name
{main} % node text
{right=of 2d6c035} % node placement
{2d6c035} % target
\gitHEAD
{above=of main} % node placement
{main} % target
\end{tikzpicture}
\begin{itemize}
\item \textbf{2d6c035} est l'ID du commit (l'ID complet est un SHA1)
\item \textbf{main} est une référence au dernier commit de la branche qui porte le même nom, sur le dépôt distant
\item On peut avoir plusieurs branches et donc plusieurs références (\textbf{main}, \textbf{dev}, \textbf{feature1} etc.)
\item On trouvera aussi \textbf{master} à la place de \textbf{main}
\item \textbf{main} ou \textbf{master} sont par convention des noms de branches de production
\end{itemize}
\end{block}
\end{frame}
\begin{frame}
\begin{exampleblock}{Exercice \Roman{exampleBlockCounter} - Premier pas avec GitHub}
\begin{enumerate}
\setcounter{enumi}{2}
\item Modifier le fichier README.md sur GitHub
\end{enumerate}
\end{exampleblock}
\pause
\begin{block}{État après le deuxième commit sur github}
\centering
\begin{tikzpicture}
\gitDAG[grow right sep = 2em]{2d6c035 -- 4f55e02};
\gitremotebranch
[main] % node name
{main} % node text
{right=of 4f55e02} % node placement
{4f55e02} % target
\gitHEAD
{above=of main} % node placement
{main}
\end{tikzpicture}
\end{block}
\end{frame}
\begin{frame}
\begin{alertblock}{Heads}
\justifying
A head is simply a reference to a commit object. Each head has a name. By default, there is a head in every repository called master (or main). A repository can contain any number of heads. At any given time, one head is selected as the “current head.” This head is aliased to HEAD, always in capitals.
Note this difference: a “head” (lowercase) refers to any one of the named heads in the repository; “HEAD” (uppercase) refers exclusively to the currently active head. This distinction is used frequently in Git documentation.
\end{alertblock}
\centering
\textcolor{blue}{
\textbf{\underline{\href{https://www.cduan.com/technical/git/git-1.shtml\#heads}{Git - Heads}}}}
\end{frame}
\begin{frame}
\begin{exampleblock}{Exercice \Roman{exampleBlockCounter} - Premier pas avec GitHub}
\begin{enumerate}
\setcounter{enumi}{3}
\item Créer une nouvelle branche nommée \textbf{dev}
\item Sur la branche \textbf{dev}, modifier le fichier README.md
\end{enumerate}
\end{exampleblock}
\begin{block}{État juste après la création de la branche \textbf{dev}}
\centering
\begin{tikzpicture}
\gitDAG[grow right sep = 2em]{2d -- 4f};
\gitremotebranch
[main] % node name
{main} % node text
{below=of 4f} % node placement
{4f} % target
\gitbranch
[dev] % node name
{dev} % node text
{right=of 4f} % node placement
{4f} % target
\gitHEAD
{right=of dev} % node placement
{dev}
\end{tikzpicture}
\end{block}
\pause
\begin{block}{État juste après le commit dans la branche \textbf{dev}}
\centering
\begin{tikzpicture}
\gitDAG[grow right sep = 2em]{
2d -- 4f -- {
67
}
};
\gitremotebranch
[main] % node name
{main} % node text
{below=of 4f} % node placement
{4f} % target
\gitbranch
[dev] % node name
{dev} % node text
{right=of 67} % node placement
{67} % target
\gitHEAD
{below=of dev} % node placement
{dev}
\end{tikzpicture}
\end{block}
\end{frame}
\begin{frame}
\begin{alertblock}{Concepts importants à retenir}
\begin{itemize}
\item Branches
\item Commits
\item Heads (références, pointeurs)
\item Toute branche a son pointeur de même nom qui référence toujours le dernier commit de la branche
\item HEAD est le seul pointeur qui peut bouger. C'est à partir de lui que sera créé le prochain commit.
\end{itemize}
\end{alertblock}
\end{frame}
\stepcounter{exampleBlockCounter}
\subsection{Installation \& utilisation en local - Les commandes de base}
\begin{frame}
\begin{exampleblock}{Exercice \Roman{exampleBlockCounter} - Installation de Git en local}\stepcounter{exampleBlockCounter}
\begin{enumerate}
\item Installer Git en suivant le lien suivant : \textcolor{blue}{\textbf{\underline{\href{https://git-scm.com}{Git - SCM}}}}
\center{
\includegraphics[scale=0.35]{images/GitInstaller.PNG}
\captionof{figure}{Git Setup - Garder les options par défaut}}
\end{enumerate}
\begin{enumerate}
\setcounter{enumi}{1}
\item Créer un dossier GIT sur votre machine
\item Importer votre dépôt FirstRepository dans ce dossier
\end{enumerate}
\end{exampleblock}
\end{frame}
\subsection*{Commandes clone \& remote}
\begin{frame}
\center{
\includegraphics[scale=0.675]{images/GitCloneRemote.PNG}
\captionof{figure}{Commandes clone et remote}}
\end{frame}
\begin{frame}
\center{
\includegraphics[scale=0.425]{images/configFile.PNG}
\captionof{figure}{Dossier .git et fichier config}}
\end{frame}
\begin{frame}
\begin{alertblock}{remote "origin" ?}
\begin{itemize}
\item origin est un alias local donné au dépôt distant
\item il peut être changé dans le fichier config ...
\center{
\includegraphics[scale=0.5]{images/origin1.PNG}
\captionof{figure}{Changer l'alias origin}}
\end{itemize}
\centering
\end{alertblock}
\end{frame}
\begin{frame}
\begin{alertblock}{... ou lors de la commande clone}
\center{
\includegraphics[scale=0.45]{images/origin2.PNG}
\captionof{figure}{Changer l'alias origin}}
\end{alertblock}
\end{frame}
\begin{frame}
\begin{alertblock}{Comment supprimer un dépôt local ?}
\center{
\includegraphics[scale=0.65]{images/deleteLocalRepository.PNG}
\captionof{figure}{Supprimer un dépôt local}}
\centering
\end{alertblock}
\begin{alertblock}{branch, main, fetch, push, merge etc. ?}
\center{
C'est le vocabulaire des DVCS (Git)\\
Plus clair progressivement !}
\centering
\end{alertblock}
\end{frame}
\begin{frame}[containsverbatim]{Petit résumé intermédiaire}
\begin{alertblock}{Quelques Commandes : clone, status, log, switch}
\begin{lstlisting}
$ git clone url # Clone repository
$ git remote -v # Remotes infos
$ git status # Git status
$ git log # Print commits
$ git log --oneline # Print abbrev-commits
$ git switch branchName # Move HEAD to branchName
\end{lstlisting}
\end{alertblock}
\begin{alertblock}{Il existe un répertoire .git}
\begin{itemize}
\item Il contient la base de donnée locale du dépôt : dépôt local
\item Il contient un fichier de configuration du dépôt
\end{itemize}
\end{alertblock}
\end{frame}
\begin{frame}[containsverbatim]{Petit résumé intermédiaire}
\begin{alertblock}{I need help !}
\begin{lstlisting}
$ git commit help # open html page on "commit" command
$ git remote -h # Quick "remote" help in console
\end{lstlisting}
\end{alertblock}
\end{frame}
\subsection*{Commandes fetch \& checkout}
\begin{frame}
\center{
\includegraphics[scale=0.4]{images/GitFetchCheckout.PNG}
\captionof{figure}{Importer un dépôt distant - Version 2}}
\end{frame}
\begin{frame}
\center{
\includegraphics[scale=0.4625]{images/GitFetchCheckout2.PNG}
\captionof{figure}{Importer un dépôt distant - Les deux versions}}
\end{frame}
\subsection*{Commandes pull \& merge}
\begin{frame}
\begin{exampleblock}{Exercice \Roman{exampleBlockCounter} - Changements à partir du dépôt distant}\stepcounter{exampleBlockCounter}
\begin{enumerate}
\item Changer le fichier README sur github (branche main)
\item Reporter ces changements en local
\end{enumerate}
\end{exampleblock}
\center{
\includegraphics[scale=0.5]{images/GitPull.png}
\captionof{figure}{Mettre à jour un dépôt local - Les deux versions}}
\end{frame}
\begin{frame}
\center{
\includegraphics[scale=0.45]{images/gitpullTerminal.png}
\captionof{figure}{Mettre à jour un dépôt local - Version 1}}
\end{frame}
\begin{frame}
\center{
\includegraphics[scale=0.4]{images/gitFetchMerge.png}
\captionof{figure}{Mettre à jour un dépôt local - Version 2}}
\end{frame}
\subsection*{Commande fetch \& option --dry-run}
\begin{frame}
\center{
\includegraphics[scale=0.35]{images/gitFetchDryRun.png}
\captionof{figure}{Le dépôt local est-il à jour ? Non !}
}
\center{
\includegraphics[scale=0.35]{images/gitFetchDryRun2.png}
\captionof{figure}{Maintenant oui !}}
\end{frame}
\subsection*{Installation \& utilisation en local}
\begin{frame}[containsverbatim]{Petit résumé intermédiaire}
\begin{alertblock}{Quelques commandes : pull, fetch}
\begin{lstlisting}
$ git pull origin # Get from origin
$ git fetch origin && git merge # Idem !
$ git fetch origin --dry-run # Has origin changed ?
$ git log # Print commits
$ git log --oneline # Print abbrev-commits
\end{lstlisting}
\end{alertblock}
\end{frame}
\subsection*{Commandes add, commit \& push}
\begin{frame}
\begin{exampleblock}{Exercice \Roman{exampleBlockCounter} - Changements à partir du dépôt local}\stepcounter{exampleBlockCounter}
\begin{enumerate}
\item Changer le fichier README en local (branche main)
\item Reporter ces changements en distant
\end{enumerate}
\end{exampleblock}
\center{
\includegraphics[scale=0.375]{images/gitPush.png}
\captionof{figure}{Mettre à jour le dépôt distant}}
\end{frame}
\begin{frame}
\center{
\includegraphics[scale=0.3]{images/gitStaging.png}
\captionof{figure}{Zone de transit}}
\end{frame}
\begin{frame}
\center{
\includegraphics[scale=0.3]{images/gitPush2.png}
\captionof{figure}{Mettre à jour le dépôt distant}}
\end{frame}
\subsection*{Personal Access Token}
\begin{frame}
\center{
\includegraphics[scale=0.55]{images/GenerateToken.png}
\captionof{figure}{Génération d'un jeton dans GitHub}}
\begin{alertblock}{Génération d'un jeton d'accès personnel}
\begin{itemize}
\item Conserver ce jeton. Il n'est visible qu'une seule fois !
\item C'est bien de lui donner un petit nom (note) !
\item Ne pas oublier de sélectionner l'option "repo"
\item Sur un dépôt privé, rien n'est possible sans jeton
\end{itemize}
\end{alertblock}
Pour plus d'infos : \textcolor{blue}{\textbf{\underline{\href{https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens}{Personal Access Token (PAT)}}}}
\end{frame}
\subsection*{Commandes add, commit \& push}
\begin{frame}
\center{
\includegraphics[scale=0.4]{images/gitPush3.png}
\captionof{figure}{Avec le jeton comme mdp, le push fonctionne}}
\end{frame}
\begin{frame}[containsverbatim]
\begin{alertblock}{Pour enregistrer le jeton}
\begin{lstlisting}
$ git config --global credential.helper store
\end{lstlisting}
\justifying ... et ne plus avoir à le retaper qu'une seule fois. Le jeton est enregistré dans le fichier texte \textbf{.git-credentials} de votre répertoire personnel.
\end{alertblock}
\begin{alertblock}{Pour signer les commits automatiquement}
\begin{lstlisting}
$ git config --global user.email "mail@somewhere.com"
$ git config --global user.name "username"
\end{lstlisting}
\centering\textbf{Signed-off-by: username \textless mail@somewhere.com\textgreater}
\end{alertblock}
\begin{alertblock}{Pour cloner (ou autre) on peut aussi faire :}
\begin{lstlisting}
$ git clone https://uname:pass@github.com/uname/rp.git
\end{lstlisting}
\end{alertblock}
\end{frame}
\begin{frame}[containsverbatim]{Petit résumé intermédiaire}
\begin{alertblock}{Quelques commandes : add, commit}
\justifying
\begin{lstlisting}
$ git add fileName # Stage fileName
$ git add . # Stage modified and new files
$ git add -u # Stage modified and deleted files
$ git add -A # Stage everything
$ git commit -m "A commit message"
\end{lstlisting}
\end{alertblock}
\end{frame}
\begin{frame}[containsverbatim]
\begin{alertblock}{D'autres commandes utiles ! switch, branch, checkout}
\justifying
\begin{lstlisting}
$ git switch branchName # Switch to branchName
$ git checkout 52fd6e4 # In detached HEAD
$ git checkout branchName # HEAD on branchName
$ git branch -D branchName # To delete branchName
$ git branch # List all local branches
$ git branch -r # List all remote branches
$ git branch -a # List all branches
$ git branch newBranchName # Create new branch
$ git switch -c neBrNa # Create & switch to neBrNa
\end{lstlisting}
\end{alertblock}
\end{frame}
\subsection{Les zones de Git}
\begin{frame}[containsverbatim]
\center{
\includegraphics[scale=0.3]{images/zones1.png}}
\end{frame}
\begin{frame}[containsverbatim]
\center{
\includegraphics[scale=0.3]{images/zones2.png}}
\centering
\textbf{\textcolor{red}{stash = réserve, remise}}
\end{frame}
\subsection{Annuler un commit : commande revert}
\begin{frame}[fragile]
\begin{exampleblock}{Exercice \Roman{exampleBlockCounter} - Commande revert}
\begin{enumerate}
\item Ajouter un nouveau commit dans la branche \textbf{main} en modifiant le fichier README.md (Before revert)
\item Utiliser la commande revert pour annuler ce commit
\item Utiliser la commande checkout pour vous déplacer dans les commits
\end{enumerate}
\end{exampleblock}
\pause
\begin{alertblock}{Commande revert}
\begin{lstlisting}
$ git switch main # Goto main branch
$ vim README.md # Modify README
$ git commit -am "Before revert" # Commit
$ git revert HEAD # Revert last commit
$ git log --oneline # See logs
$ cat README.md # File content
$ git checkout 44e5761 # Goto previous commit
$ cat README.md # File content
\end{lstlisting}
\end{alertblock}
\end{frame}
\begin{frame}
\begin{alertblock}{Commande revert}
\begin{itemize}
\justifying
\item Elle ne modifie pas l'historique des commits (pas de suppression de commits)
\item Elle crée un nouveau commit
\item Elle détermine comment inverser les changements introduits par le commit spécifié et ajoute un nouveau commit avec le contenu inversé qui en résulte
\end{itemize}
\end{alertblock}
\end{frame}
\stepcounter{exampleBlockCounter}
\subsection{Modifier l'historique des commits : commande reset}
\begin{frame}[fragile]
\begin{exampleblock}{Exercice \Roman{exampleBlockCounter} - Commande reset}
\begin{enumerate}
\item Modifier le fichier README.md sans faire de commit
\item Supprimer les deux derniers commits (le Before revert et le revert) précédents en utilisant la commande reset
\item Conclusion
\end{enumerate}
\end{exampleblock}
\pause
\begin{alertblock}{Commande reset}
\begin{lstlisting}
$ git checkout main # HEAD to main
$ vim README.md # Change README.md
$ git log --oneline # See logs
$ git reset 9d49258 # Reset two commits
$ git log --oneline # See logs
$ cat README.md # File content
$ git restore README.md # Get from index
$ cat README.md # File content
\end{lstlisting}
\end{alertblock}
\end{frame}
\begin{frame}
\center{
\includegraphics[scale=0.5]{images/reset.png}
\captionof{figure}{Commande reset - Les différents modes}}
\end{frame}
\begin{frame}
\begin{alertblock}{Commande reset - Option mixed}
\begin{itemize}
\justifying
\item Elle revient dans l'état du commit spécifié en mettant l'index (staging area) à jour mais pas la copie de travail
\item Elle modifie l'historique des commits (supprime des commits)
\item La commande restore permet de récupérer l'index : git restore README.md
\item C'est l'option par défaut : mode mixte
\end{itemize}
\end{alertblock}
\centering
\textbf{\textcolor{red}{"git reset idCommit" et "git reset -\smallskip-mixed idCommit" sont donc des commandes indentiques}}
\end{frame}
\begin{frame}[fragile]
\begin{alertblock}{Commande reset - Options soft, mixed et hard}
\begin{itemize}
\justifying
\item Récupérer l'état de certains fichiers et conserver les modifications en cours pour les autres fichiers
\item Réécrire l'historique des commits dans le dépôt (e.g. regrouper des commits)
\end{itemize}
\end{alertblock}
\begin{alertblock}{Comment annuler un reset ?}
\justifying
Quelle que soit l'option utilisée, il est toujours possible d'annuler un reset en retrouvant l'ID des commits par la commande reflog
\begin{lstlisting}
$ git reflog # get idCommit just before reset
$ # reset hard to this commit
$ git reset --hard idCommit
\end{lstlisting}
\end{alertblock}
\center{
\textbf{\textcolor{red}{-\smallskip-hard reste une option dangereuse !}}}
\end{frame}
\stepcounter{exampleBlockCounter}
\subsection{Fusionner et rebaser des branches - Résolution de conflits}
\begin{frame}[fragile]
\begin{exampleblock}{Exercice \Roman{exampleBlockCounter} - Préparation fusion et rebase}
\begin{enumerate}
\item Ajouter un nouveau commit dans la branche \textbf{dev}
\end{enumerate}
\end{exampleblock}
\pause
\begin{alertblock}{Préparation fusion et rebase}
\begin{lstlisting}
$ git switch dev # Goto dev branch
$ vim README.md # Modify README
$ git commit -am "devC1" # Commit 1 in dev branch
\end{lstlisting}
\end{alertblock}
\end{frame}
\stepcounter{exampleBlockCounter}
\begin{frame}
\begin{block}{État actuel du dépôt local}
\centering
\begin{tikzpicture}
\gitDAG[grow right sep = 2em]{
2d -- 4f -- {
ad -- c4,
67 -- 32,
}
};
\gitremotebranch
[main] % node name
{main} % node text
{right=of c4} % node placement
{c4} % target
\gitbranch
[dev] % node name
{dev} % node text
{right=of 32} % node placement
{32} % target
\gitHEAD
{right=of main} % node placement
{main}
\end{tikzpicture}