summaryrefslogtreecommitdiffstats
path: root/git.tex
blob: 8e995150870c1ad61a871c565b6e75ac2fc5ab5b (plain)
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
% vim: set tabstop=4:
% vim: set shiftwidth=4:
% vim: set expandtab:

\RHpresentationHead{
    \documentclass[pdftex,unicode,xcolor=table,slidestop,compress]{beamer}
}

\RHarticleHead{
    % This does not work, because of colors, \insertauthor, etc.
    \documentclass[a4paper,12pt,pdftex,unicode]{article}
    \usepackage[envcountsect]{beamerarticle}
}

%\usepackage{pgfpages}
\usetheme{Git}
\setbeamertemplate{navigation symbols}{}
\setbeamercovered{transparent=5}

\usepackage[utf8]{inputenc}
%\usepackage[lang]{babel}
\usepackage{setspace,amsfonts,calc,upquote,hyperref,floatflt,graphicx}
\usepackage[table]{xcolor}
\usepackage{colortbl}
\usepackage[absolute,overlay]{textpos}

% Automatically create section page
\newcommand{\sectionpage}{\usebeamertemplate*{section page}}
\AtBeginSection[]%
{
    \begin{rhbg}
        \frame{\sectionpage}
    \end{rhbg}
}

\defverb\verbemail|Random Hacker <rand@hacker.com>|
\defverb\kzakemail|<kzak@redhat.com>|

% presentation title/author/etc.
\title{Git}
\subtitle{(Why not CVS? ... because Git.)}
\author{Karel Zak \and\\
Florian Festi \and\\
Bart Trojanowski}


\begin{document}

\begin{rhbg}
    \begin{frame}
        \titlepage
    \end{frame}
\end{rhbg}

\begin{frame}[plain]
\vspace*{15ex}
Copyright \copyright{}\ \ \the\year\ \ Karel Zak\\
Copyright \copyright{}\ \ \the\year\ \ Tomas Janousek (beamer template)\\
Copyright \copyright{}\ \ \the\year\ \ Florian Festi\\
Copyright \copyright{}\ \ \the\year\ \ Bart Trojanowski\\
\vspace*{2ex}
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.2
or any later version published by the Free Software Foundation;
with no Invariant Sections, no Front-Cover Texts, and no Back-Cover
Texts.
\par\vspace*{5ex}
\scriptsize{ Source code: http://kzak.fedorapeople.org/git-presentation.git }
\end{frame}

% table of contents
\begin{frame}
    \frametitle{Agenda}
    \tableofcontents
\end{frame}

\section{Intro}

\begin{frame}
    \frametitle{What is Git?}
    \begin{quote}
    ``I'm an egotistical bastard, and I name all my projects after myself. First 'Linux', now 'git'.'' (Linus Torvalds)
    \end{quote}
    \vspace*{4ex}
    \begin{itemize}
        \item fast distributed revision control system
        \item unusually rich command set
        \item provides both high-level operations and full access to internals
        \item originally created by Linus Torvalds for kernel development
        \item design was inspired by BitKeeper and Monotone
        \item GNU General Public License, version 2
    \end{itemize}
\end{frame}

\begin{frame}
    \frametitle{Basic features}
    \begin{itemize}
        \item distributed development model
        \item support for non-linear development (branching and merging)
        \item ready for large projects (very good performance)
        \item repositories can be easily published (git://, ssh://, http://, rsync://, ...)
        \item cryptographic authentication of history (GPG-signed tags)
        \item internally objects are addressed by content (SHA-1) -- not filenames
        \item local branches are local only (off-line work)
    \end{itemize}
\end{frame}

\subsection{Development model}

\begin{frame}
    \frametitle{Centralized model}
    \resizebox{7cm}{4cm}{\includegraphics{git-centralized.png}}
    \begin{itemize}
        \item extra policy for write access
        \item SCM is not development tool, but source code archive only
        \item every change has impact to all developers
        \item no privat branches
        \item needs connection to server for most operations
    \end{itemize}
\end{frame}

\begin{frame}
    \frametitle{Distributed model}
    \resizebox{8cm}{5cm}{\includegraphics{git-distributed.png}}
    \begin{itemize}
        \item maintainer has full control over primary (his) repository
        \item support for non-linear development
        \item repositories can be easily published (git://, ssh://, http://, ...)
    \end{itemize}
\end{frame}

\begin{frame}
    \frametitle{Git improves your work manners and habits}
    \begin{itemize}
        \item
            branching and merging is cheap

        \begin{itemize}
            \item you can prototype
            \item you can collaborate with others developers on incomplete and unstable stuff
            \item you can easily (e.g. every day) rebase your changes to new upstream code
            \item merge (rebase) often minimizes conflicts between your patches and upstream
        \end{itemize}

        \item
            small patch is the best patch (patch per feature/change)

        \begin{itemize}
            \item reviewers hate huge patches
            \item well separated feature or change is easy to revert
            \item per item commit messages
        \end{itemize}
        \item much less dependent on your patches going in upstream
        \item manage patches - not just store them
    \end{itemize}
\end{frame}

\begin{frame}[containsverbatim]
    \frametitle{Workflow}
    Changes go through several stages before ending up in their final destination
    \begin{description}[master branch]
        \item[working dir] current checkout - editing happens here
        \item[index] aka ``cache'' aka ``staging area'' - changes that are selected to be commited
        \item[commit] now packaged up with a commit message and part of the history
        \item[master branch] move the commits over when the feature is finished
        \item[origin] get the changes upstream
    \end{description}
\end{frame}

\subsection{Commands}

\begin{frame}[containsverbatim]
    \frametitle{Syntax}
    \begin{itemize}
        \item \texttt{git <commandname> [options]}
        \item \texttt{git-<commandname> [options]}
        \item \texttt{man git-<commandname>}
        \item \texttt{git help <commandname>}
    \end{itemize}

    \begin{exampleblock}{High level commands: Porcelain}
    	\begin{verbatim} $ git commit -a -s -m "cool change" \end{verbatim}
    \end{exampleblock}
    \begin{exampleblock}{Low level commands: Plumbing}
    	\begin{verbatim} $ git rev-list --pretty=oneline v2.13.. \end{verbatim}
    \end{exampleblock}
\end{frame}

\begin{frame}
    \frametitle{Basic commands (local)}
    \begin{description}[git commit]
        \item[git init] creates en empty repository at \texttt{./.git}
        \item[git add] adds file contents to the next commit
        \item[git rm] removes a file
        \item[git mv] move a file
        \item[git status] shows the working tree status
        \item[git commit] records changes to the repository
        \item[git log] shows commit log
        \item[git show] shows commit (or another object)
    \end{description}
\end{frame}

\begin{frame}
    \frametitle{Basic commands (remote)}
    \begin{description}[git format-patch]
        \item[git fetch] get new changes from external repository
        \item[git pull] fetch + merge
        \item[git push] write new changes to external repository
        \item[git format-patch] exports a change
        \item[git send-email] sends patch(s)
        \item[git am] applies a series of patches from a mailbox
    \end{description}
\end{frame}

\begin{frame}
    \frametitle{Advanced Commands (local)}
     \begin{description}[git cherry-pick]
        \item[git branch] create/modify/delete branches
        \item[git checkout] switch work dir to another branch/commit
        \item[git merge] merge two or more branches
        \item[git rebase] changes starting point of a branch
        \item[git cherry-pick] copy patch from another branch
        \item[git reset] set back a branch HEAD
        \item[git bisect] find the breaking patch
        \item[git stash] save/restore current work dir changes
        \item[git gc] compactify repository and do clean ups
    \end{description}
\end{frame}

\section{Implementation}
\subsection{Internal objects}

\begin{frame}
    \frametitle{Internal objects}
    \begin{block}{}
       All objects are content-addressable by SHA-1.
    \end{block}

    \begin{description}[references]
        \item[commit] refers to ``tree'' and ``parent'' (connection into the project history) and contains the commit message
        \item[tree] represents the state of a single directory (list of ``blob'' objects and subtrees)
        \item[blob] contains file data without any other structure
    \end{description}
\end{frame}

\begin{frame}
    \frametitle{Internal objects}
    \resizebox{8cm}{4cm}{\includegraphics{git-objdb.png}}
    \begin{description}[commit]
        \item[commit] -- connection between ``tree'' and ``parent``
        \item[tree] -- state of a single directory
        \item[blob] -- contain file data
    \end{description}
\end{frame}

\begin{frame}
    \frametitle{References}
    \begin{itemize}
        \item Tag
        \begin{itemize}
                \item contains SHA-1 sum of a commit
                \item may contain an explaining message
                \item can be PGP-signed
                \item stays fix
                \item .git/refs/tags
        \end{itemize}
        \item Branch
        \begin{itemize}
                \item SHA-1 sum of a commit
                \item ``leaf'' of the history ``tree''
                \item follows the commits to that branch
                \item .git/refs/heads
        \end{itemize}
        \item tracked branches - .git/refs/remotes/ origin
        \item HEAD - the current branch 
        \item ORIG\_HEAD - HEAD before the last reset
    \end{itemize}
\end{frame}

\begin{frame}[containsverbatim]
    \frametitle{Trust}
    \begin{itemize}
        \item everything is content-addressed and based on SHA-1
        \item two trees are same when HEAD SHA-1 are same
        \item SHA-1 summ are checked to asure data integrity
        \item content, history and commit messages can be signed by only GPG-signing one tag
    \end{itemize}

    \begin{exampleblock}{}
    \scriptsize{
    	\begin{verbatim}
 $ git tag -v v2.13
 object 49ef7acdf77066ed05a6c828c261d332c4f54644
 type commit
 tag v2.13
 tagger Karel Zak <kzak@redhat.com> Tue Aug 28 01:01:35 2007 +0200

 stable release v2.13
 gpg: Signature made Tue 28 Aug 2007 01:01:35 AM CEST using DSA key ID DC06D885
 gpg: Good signature from "Karel Zak <kzak@redhat.com>" \end{verbatim}
    }
    \end{exampleblock}
\end{frame}


\subsection{Naming revisions}

\begin{frame}[containsverbatim]
    \frametitle{Object reference}
    \defverb\ngrandparent|commit~n|
    \defverb\nparent|commit^n|
    \begin{description}[ref@\{date\}]
        \item[SHA-1] 40-hexdigit object name
        \item[tag] human readable name for commit
        \item[\nparent] N-th parent
        \item[\ngrandparent] N-th generation grand-parent of the named commit object, following only the first parent.
        \item[ref@\{date\}] specify the value of the ref at a prior point in time
        \item[:/text] commit whose commit message starts with the specified text
        \item[HEAD] refers to the head of the current branch
    \end{description}

    \begin{exampleblock}{}
        \begin{verbatim} rev~3   =    rev^^^    =   rev^1^1^1 \end{verbatim}
    \end{exampleblock}

    \begin{exampleblock}{}
        \begin{verbatim} $ git reset HEAD^ \end{verbatim}
    \end{exampleblock}
\end{frame}

\begin{frame}[containsverbatim]
    \frametitle{Ranges}
    \begin{description}[r1...r2]
        \item[r1..r2] commits reachable from r2 but exclude the ones reachable from r1
        \item[r1...r2] set of commits that are reachable from either one of r1 or r2 but not from both
    \end{description}

    \begin{exampleblock}{}
        \begin{verbatim} $ git log v2.13..v2.14 \end{verbatim}
    \end{exampleblock}
\end{frame}

\begin{frame}
    \frametitle{"tree-ish"}
    Lots of commands take a tree as an argument. A tree can be referred to in many different ways, by:

    \begin{itemize}
        \item name for that tree
        \item name of a commit that refers to the tree
        \item name of a branch whose head refers to that tree
    \end{itemize}
\end{frame}

\section{Getting started}
\subsection{Configuration}

\begin{frame}[containsverbatim]
    \frametitle{Configuration}
    global configuration is in $\sim$/.gitconfig
    \begin{exampleblock}{}
    \begin{verbatim} $ git config --global --list
    user.name=Florian Festi
    user.email=ffesti@redhat.com
    diff.color=auto\end{verbatim}
    \end{exampleblock}
    repository configuration is in repo/.git/config
    \begin{exampleblock}{}
    \begin{verbatim} $ git config --list\end{verbatim}
    \end{exampleblock}
    changing settings
    \begin{exampleblock}{}
    \begin{verbatim} $ git config --global user.name "Florian Festi"
 $ git config --global user.email ffesti@redhat.com \end{verbatim}
    \end{exampleblock}
\end{frame}

\begin{frame}[containsverbatim]
    \frametitle{.gitconfig}
simple sample config
    \begin{exampleblock}{}
    \begin{verbatim}[user]
        name= Florian Festi
        email = ffesti@redhat.com
[diff]
        color = auto
\end{verbatim}
\end{exampleblock}
see \texttt{man git-config} for all config options
\end{frame}

\begin{frame}[containsverbatim]
    \frametitle{Create a repository}

    \begin{itemize}
        \item create a new repository
            \begin{exampleblock}{}
                \small{
                \begin{verbatim}
 $ mkdir project
 $ cd project
 $ git init \end{verbatim}
            }
             \end{exampleblock}
        \item clone an existing remote repository ("origin" repository)
            \begin{exampleblock}{}
                \small{ \begin{verbatim} $ git clone http://foo.com/project \end{verbatim} }
            \end{exampleblock}
        \item add a next remote repository
            \begin{exampleblock}{}
                \small{
                \begin{verbatim} $ git config remote.bar.url git://bar.com/project
 $ git config remote.bar.fetch master:refs/remotes/bar/master
 $ git fetch bar \end{verbatim}
                }
            \end{exampleblock}
    \end{itemize}
\end{frame}

\begin{frame}[containsverbatim]
     \frametitle{Repository config file}
    \begin{exampleblock}{}
    \begin{verbatim}
[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
[remote "origin"]
        url = ssh://login.linux.duke.edu/.../yum.git
        fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
        remote = origin
        merge = refs/heads/master
\end{verbatim}
\end{exampleblock}
\end{frame}


\subsection{Visualisation}

\begin{frame}
    \frametitle{Visualisation}
    \begin{itemize}
        \item visualization helps when working with branches
        \item http://git.or.cz/gitwiki/InterfacesFrontendsAndTools
    \end{itemize}
History viewer:
    \begin{description}
        \item[gitk] Tcl/Tk History Viewer
        \item[qgit] Qt History Viewer, patch import/export
        \item[gitweb] Web front end (CGI, mod\_perl) 
    \end{description}
Commit tools
    \begin{description}
        \item[git gui] Tcl/Tk, builtin
    \end{description}
\end{frame}

\begin{frame}
    \frametitle{Visualisation: gitk}
    \includegraphics[width=0.9\textwidth]{gitk.png}
\end{frame}

\begin{frame}
    \frametitle{Visualisation: qgit}
    \includegraphics[width=0.9\textwidth]{qgit.png}
\end{frame}

\begin{frame}
    \frametitle{Visualisation: Gitweb}
	\includegraphics[width=0.9\textwidth]{gitweb.png}
\end{frame}

\begin{frame}[containsverbatim]
    \frametitle{Browsing changes}
    \begin{description}[git whatchanged]
        \item[git log] shows commit logs
        \item[git show] shows one or more objects (blobs, trees, tags and commits)
        \item[git blame] shows what revision and author last modified each line of a file
        \item[git whatchanged] shows logs with difference each commit introduces
    \end{description}
    \begin{exampleblock}{}
    \begin{scriptsize}
        \begin{verbatim}
$ git log v2.5..                     # commits since v2.5
$ git log test..master               # commits reachable from master
                                     #         but not test
$ git log --since="2 weeks ago"      # commits from the last 2 weeks
$ git log Makefile                   # commits which modify Makefile
$ git log --pretty=format:"%h [%an]" # commit log in format
                                     #        "sha-1 [Author Name]"
$ git blame -L 10,15 foo.c           # who modified code between lines
                                       10 and 15
$ git show c1a47c171b                # shows selected object (commit) \end{verbatim}
    \end{scriptsize}
    \end{exampleblock}
\end{frame}

\section{Branches}

\begin{frame}[containsverbatim]
    \frametitle{Branches}
    \begin{exampleblock}{}
        \begin{verbatim}
         o--o--o   <-- Branch A
        /
 o--o--o--o--o     <-- master
        \
         o--o--o   <-- Branch B  \end{verbatim}
    \end{exampleblock}

    \begin{description}[branch head]
        \item[branch] is line of development
        \item[branch head] is a reference to the most recent commit on a branch
    \end{description}
    \begin{itemize}
        \item branches become remote branches when cloning a repository
        \item use \texttt{git branch -a} (all) or \texttt{-r} (remote) to see the remote branches  
    \end{itemize}

\end{frame}

\begin{frame}[containsverbatim]
    \frametitle{Manipulating branches}
    \defverb\branchname|<branch>|
    \begin{itemize}
        \item \structure{git branch} lists, creates, or deletes branches
        \item \structure{git checkout \branchname} makes the current branch \branchname, updating the working directory
        \item \structure{git checkout -b \branchname} creates a new branch \branchname check it out
        \item \structure{git show-branch} shows branches and their commits
        \item \structure{git diff \branchname..\branchname} diffs between branches
    \end{itemize}
\end{frame}

\begin{frame}[containsverbatim]
    \frametitle{Merge branch}
    \begin{exampleblock}{Before}
        \begin{verbatim}
                 A---B---C topic
                /
           D---E---F---G master \end{verbatim}
    \end{exampleblock}

    \begin{exampleblock}{Command}
        \begin{verbatim} $ git merge topic \end{verbatim}
    \end{exampleblock}

    \begin{exampleblock}{After}
        \begin{verbatim}
                 A---B---C topic
                /         \
           D---E---F---G---H master \end{verbatim}
    \end{exampleblock}
\end{frame}

\begin{frame}[containsverbatim]
    \frametitle{Rebase branch}
    \begin{exampleblock}{Before}
        \begin{verbatim}
                 A---B---C topic
                /
           D---E---F---G master \end{verbatim}
    \end{exampleblock}

    \begin{exampleblock}{Command}
        \begin{verbatim} $ git rebase master topic \end{verbatim}
    \end{exampleblock}

    \begin{exampleblock}{After}
        \begin{verbatim}
                         A---B---C topic
                        /
           D---E---F---G master \end{verbatim}
    \end{exampleblock}
    \begin{exampleblock}{Alternative}
        \begin{verbatim} $ git rebase -i topic \end{verbatim}
    \end{exampleblock}
\end{frame}

\begin{frame}
    \frametitle{Merge vs Rebase}
    \begin{itemize}
        \item Merge
        \begin{itemize}
            \item does an 3-way merge (for simple cases)
            \item leads to non linear history
            \item merging several branches with each other looks messy
            \item keeps separate branches visible
            \item Use in public repositories!
        \end{itemize}
        \item Rebase
        \begin{itemize}
            \item reapplies the patches on top
            \item alters history - new patches with new SHA-1 sums
            \item breaks work based on that branch
            \item therefore not suited for published work
            \item allows creating ``the perfect patch'' against upstream
            \item Use for private work!
        \end{itemize}
        \item Read the man pages for details!
    \end{itemize}
\end{frame}

\begin{frame}
    \frametitle{Resolve Conflicts}
    \begin{itemize}
    \item Read the messages!
    \item resolved stuff gets added to the index
    \item conflicts are applied to the work dir only
    \item resolve and add to index
    \item merge: \texttt{commit}
    \item rebase: \texttt{--continue}, \texttt{--abort} or \texttt{--skip} 
    \end{itemize}
\end{frame}

\section{Real life with Git}
\subsection{Changing History}

\begin{frame}[containsverbatim]
    \frametitle{Edit 3rd commit from the top}
    \begin{enumerate}
        \item Working on branch master
        \begin{exampleblock}{}                                                                     
        \begin{verbatim}
             A--B--C--D--E(master)\end{verbatim}
        \end{exampleblock}
        \item realized you made a mistake in commit 'B'
        \begin{exampleblock}{}
        \begin{verbatim}  $ git checkout HEAD~3
  $ git commit --amend
             .B'(HEAD)
            /
           A--B--C--D--E(master)\end{verbatim}
        \end{exampleblock}
        \item bring back the other commits
        \begin{exampleblock}{}                                                                     
        \begin{verbatim} $ git rebase HEAD master
             A--B'--C--D--E(master)\end{verbatim}
        \end{exampleblock}
    \end{enumerate}
\end{frame}

\begin{frame}
    \frametitle{Changes in project history}
    \begin{itemize}
        \item the very last patch -- \texttt{"git commit --amend"} to add changes to last commit
        \item the latest patches -- \texttt{"git reset"} to remove the last commits from the history
        \item organize your own branch
            \begin{itemize}
                \item \texttt{"git cherry-pick"} patch per patch into a new branch
                \item \texttt{"git rebase -i"} to freely reorder patches
            \end{itemize} 
        \item deep in project history
            \begin{itemize}
                \item \texttt{"git rebase"} to move around large part of the history
                \item \texttt{"git revert"} to add a reversed patch on top
            \end{itemize}
    \end{itemize}
\end{frame}

\subsection{Handling Patches}

\begin{frame}
    \frametitle{Send a patch}
    Basic rules:
    \begin{itemize}
        \item \structure{one patch per e-mail}
        \item don't use stupid e-mail clients (e.g. Outlook)
        \item \structure{don't use attachments}
        \item export patches by \texttt{git format-patch}
        \item send patches by \texttt{git send-email}

        \item well formatted patch is possible to apply by \texttt{git am}

        \item don't forget to \structure{keep correct authorship} (e.g when you are not author of the patch)

        \item \structure{use commit messages} -- a patch without comment is incomplete crap
    \end{itemize}
\end{frame}

\begin{frame}[containsverbatim]
     \frametitle{Export patches to files}
     \begin{block}{}
        \begin{verbatim} git format-patch [options] <since|range> \end{verbatim}
     \end{block}
     \begin{itemize}
        \item creates one file per patch
        \item created patches are usable by \structure{git am}
    \end{itemize}
    \begin{exampleblock}{}
    \scriptsize{
        \begin{verbatim}
$ git format-patch -o ~/ HEAD~5
/home/kzak/0001-setterm-opened-file-leaving-unclosed.patch
/home/kzak/0002-sfdisk-opened-files-leaving-unclosed.patch
/home/kzak/0003-blockdev-fix-opened-file-leaving-unclosed.patch
/home/kzak/0004-tailf-opened-file-leaving-unclosed.patch
/home/kzak/0005-tests-use-losetup-s.patch \end{verbatim}
    }
    \end{exampleblock}
\end{frame}

\begin{frame}
    \frametitle{Patch description}
	\includegraphics[width=0.9\textwidth]{git-patch.png}
\end{frame}

\begin{frame}[containsverbatim]
     \frametitle{Send patches by e-mail}
     \begin{block}{}
         \begin{verbatim} git send-email [options] <file|dir> \end{verbatim}
     \end{block}
     Takes the patches given on the command line and emails them out.\\
     \begin{itemize}
        \item no attachments
        \item no broken patch format
        \item correct subject line
     \end{itemize}
     \begin{exampleblock}{}
        \begin{verbatim}
$ git send-email --to "God <father@heaven.com>" \
                 ~/0001-make-this-world-better.patch \end{verbatim}
    \end{exampleblock}
\end{frame}


\section{Misc}


\begin{frame}
  \frametitle{References}
  \begin{thebibliography}{Git User's Manua}
  \bibitem[Git User's Manual]{GitUserManual}
    Git User's Manual
    \newblock {\url{http://www.kernel.org/pub/software/scm/git/docs/user-manual.html}}
  \bibitem[Git Tutorial]{GitTutorial}
    A tutorial introduction to git
    \newblock {\url{http://www.kernel.org/pub/software/scm/git/docs/tutorial.html}}
  \bibitem[The perfect patch]{PerfectPatch}
    The perfect patch
    \newblock {\url{http://www.zip.com.au/~akpm/linux/patches/stuff/tpp.txt}}
  \end{thebibliography}
\end{frame}

\begin{frame}[containsverbatim]
    \hfill
    \begin{center}
    {\Huge The end.}
    \par\vspace*{0.5cm}
    Thanks for listening.
    \hfill
    \par\vspace*{5cm}
    \url{http://kzak.fedorapeople.org/git-presentation.pdf}
    \end{center}
\end{frame}

\end{document}