-
Notifications
You must be signed in to change notification settings - Fork 0
/
body.tex
1262 lines (1028 loc) · 33.7 KB
/
body.tex
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
% Copyright (C) 2013 Mario Sanchez Prada
% Author: Mario Sanchez Prada <[email protected]>
%
% This presentation is distributed under the terms of the
% Creative Commons Attribution-ShareAlike 2.0:
%
% http://creativecommons.org/licenses/by-sa/2.0/
%
\section{Basic concepts}
\subsection{The problem}
\begin{frame}
\frametitle{\insertsubsection}
\textbf{Handling changes in a file, a project...} \pause
\begin{itemize}
\item Option 0: Do nothing (unique version) \pause
\vspacing
\item Option 1: Rudimentary system (manual copies)
\begin{itemize}
\item \texttt{Project}
\item \texttt{Project.bckp}
\item \texttt{Project-20130514.bckp}
\item \texttt{Project-20130514.bckp2}
\item \texttt{Project-20130514.bckp2-final}
\item \texttt{Project-20130514.bckp2-last}
\item \texttt{Project-20130514.bckp2-last-final}
\item \texttt{Project-????????} \pause
\end{itemize}
\vspacing
\item Option 2: ``Traditional'' \textit{VCS's}: \textit{CVS},
\textit{Subversion}...
\begin{itemize}
\item They normally require a connection to a central repository
\end{itemize} \pause \vspacing
\item Option 3: \textit{DVCS's}: \textit{Bazaar},
\textit{Mercurial}, \textit{Monotone}, \textbf{\git}...
\begin{itemize}
\item \textbf{Total} autonomy and flexibility (i.e. local \textit{commits})
\end{itemize}
\end{itemize}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{VCS vs DVCS}
\begin{frame}
\frametitle{\insertsubsection}
\begin{center}
\includegraphics[height=0.40\textheight]{images/pdf/vcs.pdf}
\ \\ \vspacing \vspacing \vspacing \vspacing
\only<1>{\includegraphics[height=0.35\textheight]{images/pdf/dvcs1.pdf}}
\only<2>{\includegraphics[height=0.35\textheight]{images/pdf/dvcs2.pdf}}
\only<3>{\includegraphics[height=0.35\textheight]{images/pdf/dvcs1.pdf}}
\end{center}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Advantages and disadvantages of DVCS}
\begin{frame}
\frametitle{\insertsubsection}
\begin{columns}[t]
\column{.5\textwidth}
\textbf{Advantages}
\begin{itemize}
\item Full repository in the local machine: full history,
branches, work offline...
\item Improves the \textit{workflow} for collaborative work
\item Integration of changes from external sources
\item Makes handling different versions for a project easier
\item Better separation between private and public work
\item Implicit \textit{back-up} copies
\item Enables working offline
\end{itemize}
\column{.5\textwidth}
\textbf{Disadvantages}
\begin{itemize}
\item More complex than \textit{VCS's}. Harder learning curve
\item Initially cloning is slower (not just the last commit)
\item Full clones can require more hard disk space
\end{itemize}
\end{columns}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Subversion (VCS) vs Git (DVCS)}
\begin{frame}
\frametitle{\insertsubsection}
\begin{center}
\includegraphics[height=0.30\textheight]{images/pdf/svn-layout.pdf}
\ \\ \vspacing \vspacing \vspacing
\only<1>{\includegraphics[height=0.50\textheight]{images/pdf/git-layout-solo.pdf}}
\only<2>{\includegraphics[height=0.50\textheight]{images/pdf/git-layout-remote.pdf}}
\end{center}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Typical workflow with git}
\begin{frame}
\frametitle{\insertsubsection}
\begin{center}
\includegraphics[width=1.0\textwidth]{images/pdf/git-detailed-1.pdf}
\end{center}
\end{frame}
\begin{frame}
\frametitle{\insertsubsection}
\begin{center}
\includegraphics[width=1.0\textwidth]{images/pdf/git-detailed-2.pdf}
\end{center}
\end{frame}
\begin{frame}
\frametitle{\insertsubsection}
\begin{center}
\includegraphics[width=1.0\textwidth]{images/pdf/git-detailed-3.pdf}
\end{center}
\end{frame}
\begin{frame}
\frametitle{\insertsubsection}
\begin{center}
\includegraphics[width=1.0\textwidth]{images/pdf/git-detailed-4.pdf}
\end{center}
\end{frame}
\begin{frame}
\frametitle{\insertsubsection}
\begin{center}
\includegraphics[width=1.0\textwidth]{images/pdf/git-detailed-5.pdf}
\end{center}
\end{frame}
\begin{frame}
\frametitle{\insertsubsection}
\begin{center}
\includegraphics[width=1.0\textwidth]{images/pdf/git-detailed-6.pdf}
\end{center}
\end{frame}
\begin{frame}
\frametitle{\insertsubsection}
\begin{center}
\includegraphics[width=1.0\textwidth]{images/pdf/git-detailed-7.pdf}
\end{center}
\end{frame}
\begin{frame}
\frametitle{\insertsubsection}
\begin{center}
\includegraphics[width=1.0\textwidth]{images/pdf/git-detailed-8.pdf}
\end{center}
\end{frame}
\begin{frame}
\frametitle{\insertsubsection}
\begin{center}
\includegraphics[height=0.8\textheight]{images/pdf/git-detailed-9.pdf}
\end{center}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Typical workflow with git - git push}
\begin{frame}
\frametitle{\insertsubsection}
\begin{center}
\only<1>{\includegraphics[height=0.8\textheight]{images/pdf/git-detailed-10.pdf}}
\only<2>{\includegraphics[height=0.8\textheight]{images/pdf/git-detailed-11.pdf}}
\end{center}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Typical workflow with git - git pull}
\begin{frame}
\frametitle{\insertsubsection}
\begin{center}
\only<1>{\includegraphics[height=0.8\textheight]{images/pdf/git-detailed-12.pdf}}
\only<2>{\includegraphics[height=0.8\textheight]{images/pdf/git-detailed-13.pdf}}
\end{center}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Typical workflow with git: commands}
\begin{frame}
\frametitle{\insertsubsection}
\textbf{Basic commands\only<2>{ (extended version)}:}
\begin{itemize}
\item \texttt{git init}: Initializes the repository to work with
\git \vspacing
\item \texttt{git add}: Adds changes in the \textit{Working Tree} to
the\textit{Index}
\only<2>{
\begin{itemize}
\item \texttt{git add -u}: Adds all the changes to the \textit{Index}
\item \texttt{git add \---\---patch}: Interactively asks which changes
should go to the \textit{Index} (\textit{hunk} by \textit{hunk})
\end{itemize}}
\vspacing
\item \texttt{git commit}: Makes changes in the \textit{Index}
permanent, creating a new commit and updating the \textit{HEAD}.
\only<2>{
\begin{itemize}
\item \texttt{git commit -a}: \texttt{git add -u \&\& git commit}
\end{itemize}}
\vspacing
\item \texttt{git diff}: Differences between \textit{Working Tree} and
\textit{Index}
\only<2>{
\begin{itemize}
\item \texttt{git diff HEAD}: Diff between \textit{Working
Tree} and \textit{HEAD}
\item \texttt{git diff \---\---cached}: Diff between \textit{Index} and \textit{HEAD}
\end{itemize}}
\vspacing
\item \texttt{git show <commitID>}: Visualizes details and content for \textit{commit}
\texttt{commitID} \vspacing
\item \texttt{git log}: Shows the full \textit{log} from
\textit{HEAD} \vspacing
\end{itemize}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Typical workflow with git - a specific example}
\begin{frame}[fragile]
\frametitle{\insertsubsection}
\begin{small}
\begin{verbatim}
$ mkdir /tmp/git
$ cd /tmp/git
$ git init . # Initialize repository
Initialized empty Git repository in /tmp/git/.git/
$ touch A B C
$ git add A B C # Add new files to Index
$ git commit -m "Initial commit" # First commit!
[master (root-commit) fa16ae4] Initial commit
0 files changed, 0 insertions(+), 0 deletions(-)
create mode 100644 A
create mode 100644 B
create mode 100644 C
\end{verbatim}
\end{small}
\end{frame}
\begin{frame}[fragile]
\frametitle{\insertsubsection}
\begin{small}
\begin{verbatim}
$ git diff --stat # Working Tree <-> Index
$ git diff --stat HEAD # Working Tree <-> HEAD
$ git diff --stat --cached # Index <-> HEAD
<<< MAKE SOME CHANGES IN THE WORKING TREE >>>
$ git diff --stat # Working Tree <-> Index
A | 3 +++
C | 3 +++
2 files changed, 3 insertions(+), 0 deletions(-)
$ git diff --stat HEAD # Working Tree <-> HEAD
A | 3 +++
C | 3 +++
2 files changed, 3 insertions(+), 0 deletions(-)
$ git diff --stat --cached # Index <-> HEAD
\end{verbatim}
\end{small}
\end{frame}
\begin{frame}[fragile]
\frametitle{\insertsubsection}
\begin{small}
\begin{verbatim}
$ git add A C # Move changes to Index
$ git diff --stat # Working Tree <-> Index
$ git diff --stat HEAD # Working Tree <-> HEAD
A | 3 +++
C | 3 +++
2 files changed, 3 insertions(+), 0 deletions(-)
$ git diff --stat --cached # Index <-> HEAD
A | 3 +++
C | 3 +++
2 files changed, 3 insertions(+), 0 deletions(-)
\end{verbatim}
\end{small}
\end{frame}
\begin{frame}[fragile]
\frametitle{\insertsubsection}
\begin{small}
\begin{verbatim}
$ git commit -m "My first patch :-)" # Commit changes
[master 614c4e2] My first patch :-)
2 files changed, 3 insertions(+), 0 deletions(-)
$ git diff --stat # Working Tree <-> Index
$ git diff --stat HEAD # Working Tree <-> HEAD
$ git diff --stat --cached # Index <-> HEAD
$ git show --stat HEAD # Show last commit's stats
commit 614c4e224284e2719fe040b64685b790606000a6
Author: Mario Sanchez Prada <[email protected]>
Date: Mon May 3 09:31:19 2013 +0200
My first patch :-)
A | 3 +++
C | 3 +++
2 files changed, 3 insertions(+), 0 deletions(-)
\end{verbatim}
\end{small}
\end{frame}
\begin{frame}[fragile]
\frametitle{\insertsubsection}
\begin{small}
\begin{verbatim}
$ git log # Show history up-to-date
commit 614c4e224284e2719fe040b64685b790606000a6
Author: Mario Sanchez Prada <[email protected]>
Date: Mon May 3 09:31:19 2013 +0200
My first patch :-)
commit fa16ae4ff64b3b968ca8991c90f123e62a6a009c
Author: Mario Sanchez Prada <[email protected]>
Date: Mon May 3 09:30:11 2013 +0200
Initial commit
\end{verbatim}
\end{small}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Typical workflow with git: commands}
\begin{frame}
\frametitle{\insertsubsection}
\textbf{Other helpful commands:}
\begin{itemize}
\item \texttt{git rm <file>}: Removes \texttt{file} and get the
\textit{Index} ready with the changes for the next
\textit{commit}. \vspacing
\item \texttt{git mv <fileA> <fileB>}: Renames \texttt{fileA} as
\texttt{fileB } and get the \textit{Index} ready with the changes. \vspacing
\item \texttt{git status}: Shows the status of \textit{Working
Tree} and \textit{Index} \vspacing
\item \texttt{git clone <URL>}: Clones a remote repository
\vspacing
\item \texttt{git push}: Sends local commits to a remote repository\vspacing
\item \texttt{git pull}: Brings commits from a remote repository\vspacing
\end{itemize}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile]
\frametitle{\insertsubsection: git status}
\begin{tiny}
\begin{verbatim}
<<< RIGHT BEFORE ADDING A AND C TO INDEX WITH 'git add A C' >>>
$ git status
# On branch master
# Changed but not updated:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: A
# modified: C
#
no changes added to commit (use "git add" and/or "git commit -a")
$ git add A
$ git status
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# modified: A
#
# Changed but not updated:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: C
#
\end{verbatim}
\end{tiny}
\end{frame}
\begin{frame}[fragile]
\frametitle{\insertsubsection: git show}
\begin{tiny}
\begin{verbatim}
<<< RIGHT AFTER COMMITING CHANGES WITH 'git commit' >>>
$ git show
commit 614c4e224284e2719fe040b64685b790606000a6
Author: Mario Sanchez Prada <[email protected]>
Date: Mon May 3 09:31:19 2013 +0200
My first patch :-)
diff --git a/A b/A
index e69de29..1802a74 100644
--- a/A
+++ b/A
@@ -0,0 +1,3 @@
+aaa
+bbb
+ccc
diff --git a/C b/C
index e69de29..1802a74 100644
--- a/C
+++ b/C
@@ -0,0 +1,3 @@
+aaa
+bbb
+ccc
\end{verbatim}
\end{tiny}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Comparing commands: Subversion - Git}
\begin{frame}
\frametitle{\insertsubsection}
\begin{center}
\begin{tabular}{|c|c|}
\hline \textbf{Subversion} & \textbf{Git} \\
\hline \texttt{svnadmin create \textit{repo}} & \texttt{git init} \\
\texttt{svn import \textit{filepath}} & \texttt{git add \textit{filepath}} \\
\ & \texttt{git commit} \\
\hline \texttt{svn checkout \textit{URL}} & \texttt{git clone
\textit{URL}} \\
\hline \texttt{svn add|rm|mv \textit{file}} & \texttt{git
add|rm|mv \textit{file}} \\
\hline \texttt{svn diff} & \texttt{git diff} \\
\hline \texttt{svn commit} & \texttt{git commit -a} \\
\ & \texttt{git push} \\
\hline \texttt{svn update} & \texttt{git pull} \\
\hline \texttt{svn status} & \texttt{git status} \\
\hline \texttt{svn log} & \texttt{git log} \\
\hline \texttt{svn blame \textit{file}} & \texttt{git blame
\textit{file}} \\
\hline
\end{tabular}
\end{center}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Repositories and branches}
\subsection{Local and remote repositories}
\begin{frame}
\frametitle{\insertsubsection}
\textbf{Two types} of repositories: \vspacing
\begin{itemize}
\item \textbf{Local repository}: Local working directory under
version control with \git (it contains a \texttt{.git/}
directory)\\ \vspacing They can be ``created'' by either:\vspacing
\begin{itemize}
\item \texttt{git init}: Initializes the current directory to be
used with \git (needed to \texttt{git add <file>} and
\texttt{git commit}) \vspacing
\item \texttt{git clone <URL>}: Clones a remote repository in a
local directory, stablishing a link to the original one,
throughout the remote repository \texttt{origin}.
\end{itemize} \vspacing
\item \textbf{Remote repositories}: Any non-local repository where
we have cloned our local working directory from\\
\vspacing
Can be linked with \texttt{git remote add <name> <URL>} \\
\texttt{git clone <URL>} automatically creates one: \texttt{origin}
\end{itemize}\
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{What's a branch?}
\begin{frame}
\frametitle{\insertsubsection}
A \textit{branch} is a paralell line of work which allow us to make
and try out certain changes from a given point on, without altering
the original line of work it was created from.\pause
\\ \ \vspacing
Once the changes done in the \textit{branch} have been proved to
work well, they can be integrated in the original \textit{branch},
resolving the ``conflicts'' that could have appeared since its
creation.\pause \\ \ \vspacing
Implementation:
\begin{itemize}
\item \textbf{With other \textit{VCS's} (\textit{Subversion})}: Separate directories \vspacing
\item \textbf{With \git}: An \textit{alias} to the \textit{commit}
that will be the \textit{HEAD} for that \textit{branch}
(almost-zero cost, really fast). Thus, that \textit{alias} will
get updated every time a new commit is added.
\end{itemize}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{What's a branch? - Subversion vs Git}
\begin{frame}
\frametitle{\insertsubsection}
\begin{center}
\includegraphics[width=1.0\textwidth]{images/pdf/svn-branches.pdf}
\end{center}
\begin{center}
\uncover<2->{\includegraphics[width=1.0\textwidth]{images/pdf/git-branches.pdf}}
\end{center}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Branches in git}
\begin{frame}
\frametitle{\insertsubsection}
\begin{itemize}
\item Create a new branch:\\
\texttt{git branch <branch-name> [<start-point>]}
\vspacing
\item Delete a branch:\\
\texttt{git branch (-d | -D) <branch-name>}
\vspacing
\item Rename a branch:\\
\texttt{git branch -m <old-name> <new-name>}
\vspacing
\item List the current branches:\\
\texttt{git branch [ -r | -a ]}
\vspacing
\item ``Move'' into a branch (check it out):\\
\texttt{git checkout [-b] <branch-name>}
\vspacing
\end{itemize}
\end{frame}
\subsection{Branches in git - an example}
\begin{frame}[fragile]
\frametitle{\insertsubsection}
\begin{small}
\begin{verbatim}
$ git branch
* master
$ git branch mybranch-1
$ git branch mybranch-2
$ git branch
* master
mybranch-1
mybranch-2
$ git checkout mybranch-1
Switched to branch 'mybranch-1'
$ git branch
master
* mybranch-1
mybranch-2
\end{verbatim}
\end{small}
\end{frame}
\begin{frame}[fragile]
\frametitle{\insertsubsection}
\begin{small}
\begin{verbatim}
$ git branch -m mybranch-1 branch-1
$ git branch -m mybranch-2 branch-2
$ git branch
master
* branch-1
branch-2
$ git checkout master
Switched to branch 'master'
$ git branch -d branch-1
Deleted branch branch-1 (was 59f1309).
$ git branch -d branch-2
Deleted branch branch-2 (was e721bce).
$ git branch
* master
\end{verbatim}
\end{small}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Why using branches?}
\begin{frame}
\frametitle{\insertsubsection}
\begin{itemize}
\item They are fast, convenient, and really ``cheap''\vspacing
\item To try an idea out (experiment) \vspacing
\item Separate public and private work \vspacing
\item One branch per \textit{bug}/\textit{feature} \vspacing
\item Prepare for a new \textit{release} (integration) \vspacing
\item As a temporary \textit{backup} (\textit{snapshot}) \vspacing
\item \textbf{It's the usual way of working with \git} \vspacing
\end{itemize}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Local and remote branches}
\begin{frame}
\frametitle{\insertsubsection}
\textbf{Two types} of branches:
\begin{itemize}
\item \textbf{Local branches}: Branches created in the local machine
to work on top of them, making all the needed changes.\vspacing
\item \textbf{Remote branches}: Branches from a remote repository
that we can link to local branches to work with them.
\end{itemize}\ \\ \ \\
\textbf{Clarifications}:\\
Both the \textbf{local} and the \textbf{remote} branches are always
in our \textbf{local repository} (local/remote concept depends on
the POV). \vspacing
The \textbf{remote} branches act as a \textit{cache} of non-local
branches in \textbf{remote repositories} (they are \textit{rsync-ed}). \vspacing
The \textbf{local} branches are \textit{pushed}/\textit{pulled} to/from the \textbf{remote
repositories} throughout their associated \textbf{remote} branches.
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{An example of repositories and branches: epiphany}
\begin{frame}[fragile]
\frametitle{\insertsubsection}
\begin{columns}[t]
\column{.6\textwidth}
\begin{block}{Local branches}
\begin{tiny}
\begin{verbatim}
$ git branch
136292
539716
602547
608980
* 611400
alex
master
\end{verbatim}
\end{tiny}
\end{block} \vspacing
Using branches in this example:
\begin{itemize}
\item One branch per \textit{bug} \vspacing
\item One experimental branch (\texttt{alex}) \vspacing
\item One ``main'' branch (\texttt{master}).
\end{itemize}
\column{.4\textwidth}
\begin{block}{Remote branches}
\begin{tiny}
\begin{verbatim}
$ git remote
origin
$ git branch -r
origin/HEAD -> origin/master
origin/Release043
origin/bookmarks-toolbars-changes
origin/bookmarksbar-separation
origin/css-fonts-branch
origin/eog-menu-api
origin/gnome-2-10
[...]
origin/master
origin/mozilla-embed-strings
origin/new-completion
origin/new-downloader
origin/pre-gnome-2-10
origin/pre-gnome-2-14
origin/pre-gnome-2-6
origin/pre-gnome-2-8
origin/release-1-2-1
origin/webcore-branch
origin/webkit
origin/xulrunner
\end{verbatim}
\end{tiny}
\end{block}
\end{columns}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Local and remote branches - a specific example}
\begin{frame}[fragile]
\frametitle{\insertsubsection}
\textbf{List remote branches and \textit{track} them locally}
\begin{small}
\begin{verbatim}
$ git branch -a # List ALL branches (local/remote)
* master
remotes/origin/master
remotes/origin/other-branch
$ git branch private # Create new private branch
$ git branch other-branch origin/other-branch
Branch other-branch set up to track
remote branch other-branch from origin.
$ git branch -a # List ALL branches
* master
private
other-branch
remotes/origin/master
remotes/origin/other-branch
\end{verbatim}
\end{small}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile]
\frametitle{\insertsubsection}
\textbf{Rename and remove branches}
\begin{small}
\begin{verbatim}
$ git branch -m private private-work
$ git branch -m otherbranch other-branch
$ git branch
master
* private-work
other-branch
$ git checkout master
Switched to branch 'master'
$ git branch -d private-work other-branch
Deleted branch private-work (was 59f1309).
Deleted branch other-branch (was e721bce).
$ git branch
* master
\end{verbatim}
\end{small}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile]
\frametitle{\insertsubsection}
\textbf{Send changes in local branches to a remote repository}
\begin{small}
\begin{verbatim}
<<< MAKE SOME CHANGES IN THE WORKING TREE >>>
$ git commit -a -m "Last commit"
[master 70f7c77] Last commit
1 files changed, 1 insertions(+), 0 deletions(-)
$ git push
Counting objects: 4, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 272 bytes, done.
Total 3 (delta 1), reused 0 (delta 0)
To ssh://[email protected]/var/git/myrepo.git
855a39b..70f7c77 master -> master
\end{verbatim}
\end{small}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{frame}[fragile]
\frametitle{\insertsubsection}
\textbf{Pull changes from a remote repository into a local branch}
\begin{small}
\begin{verbatim}
<<< WORKING TREE IS CLEAN (No changes) >>>
$ git pull
Updating 43f7dbc..70f7c77
Fast-forward
body.tex | 10 +++++++++-
closing.tex | 8 ++++++++
cover.tex | 8 ++++++++
opening.tex | 41 ++++++++++++-----------------------------
toc.tex | 8 ++++++++
7 files changed, 45 insertions(+), 30 deletions(-)
\end{verbatim}
\end{small}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Updating the branches}
\begin{frame}
\frametitle{\insertsubsection}
\ \vspacing
\textbf{Two typical situations}: \vspacing \ \vspacing
\begin{itemize}
\item \textbf{Add} changes in a \textbf{private branch} to a
\textbf{public branch} (integrate local changes)
\uncover<2->{
\begin{itemize}
\item We can't alter past history in a public branch
\item We need ``clean'' changes ready to be applied on top of
\textit{HEAD} in the public branch
\end{itemize}}
\vspacing
\item \textbf{Modify} a \textbf{private branch} with new code from a
\textbf{public branch} where it was created from (update)
\uncover<3>{
\begin{itemize}
\item We can alter past history in a private branch
\item It's more interesting to ``change the past'' whenever it's
needed in order to always have ``clean changes'' in the branch
where it was created from (it could have changed)
\end{itemize}}
\end{itemize}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Updating branches - git merge}
\begin{frame}[fragile]
\frametitle{\insertsubsection}
\ \vspacing
\textbf{Updating} a \textbf{public branch}: \texttt{git merge <branch>}
\vspacing
\begin{itemize}
\begin{small}
\item There are \textbf{no changes} in the public branch where the
private one was created from:
\begin{center}
\only<2>{\includegraphics[width=1.00\textwidth]{images/pdf/git-merge-A1.pdf}}
\only<3>{\includegraphics[width=1.00\textwidth]{images/pdf/git-merge-A2.pdf}}
\only<4->{\includegraphics[width=1.00\textwidth]{images/pdf/git-merge-A3.pdf}}
\end{center}
\item There are \textbf{changes} in the public branch where the
private one was created from:
\begin{center}
\only<5>{\includegraphics[width=1.00\textwidth]{images/pdf/git-merge-B1.pdf}}
\only<6>{\includegraphics[width=1.00\textwidth]{images/pdf/git-merge-B2.pdf}}
\only<7>{\includegraphics[width=1.00\textwidth]{images/pdf/git-merge-B3.pdf}}
\end{center}
\end{small}
\end{itemize}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Updating branches - git rebase}
\begin{frame}[fragile]
\frametitle{\insertsubsection}
\ \vspacing
\textbf{Update} a \textbf{private branch}: \texttt{git rebase <new-base>}
\vspacing
\begin{center}
\only<1>{\includegraphics[width=1.00\textwidth]{images/pdf/git-rebase-0.pdf}}
\only<2>{\includegraphics[width=1.00\textwidth]{images/pdf/git-rebase-1.pdf}}
\only<3>{\includegraphics[width=1.00\textwidth]{images/pdf/git-rebase-2.pdf}}
\only<4>{\includegraphics[width=1.00\textwidth]{images/pdf/git-rebase-3.pdf}}
\only<5>{\includegraphics[width=1.00\textwidth]{images/pdf/git-rebase-4.pdf}}
\end{center}
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Updating branches}
\begin{frame}[fragile]
\frametitle{\insertsubsection}
\vspacing
{\Large \textbf{One personal tip} (whenever it's possible)}\\
\vspacing Before updating a public branch with \texttt{git merge} to
do a \texttt{git push} later on, it's a good idea to do a
\texttt{git rebase} first from the private branch, in order to avoid
getting a \textit{metacommit}.
\begin{small}
\begin{verbatim}
$ git checkout mybranch # Change to private branch
$ git rebase master # Rebase private branch
$ git checkout master # Change back to master
$ git merge mybranch # Merge changes from mybranch
$ git push # Push to remote repository
\end{verbatim}
\end{small}
If \texttt{git push} fails because we are not up to date, just do:
\begin{small}
\begin{verbatim}
$ git pull --rebase
\end{verbatim}
\end{small}
This command pulls new commits from a remote branch first and then
put our local changes on top, all in one single step.
\end{frame}
%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Tags and references}
\subsection{Tags}
\begin{frame}[fragile]
\frametitle{\insertsubsection}