2 <html xmlns=
"http://www.w3.org/1999/xhtml" lang=
"en">
4 <meta charset=
"UTF-8"/>
5 <meta http-equiv=
"X-UA-Compatible" content=
"IE=edge"/>
6 <meta name=
"viewport" content=
"width=device-width, initial-scale=1.0"/>
7 <meta name=
"generator" content=
"Asciidoctor 2.0.20"/>
8 <title>My First Contribution to the Git Project
</title>
9 <link rel=
"stylesheet" href=
"https://fonts.googleapis.com/css?family=Open+Sans:300,300italic,400,400italic,600,600italic%7CNoto+Serif:400,400italic,700,700italic%7CDroid+Sans+Mono:400,700"/>
11 /*! Asciidoctor default stylesheet | MIT License | https://asciidoctor.org */
12 /* Uncomment the following line when using as a custom stylesheet */
13 /* @import
"https://fonts.googleapis.com/css?family=Open+Sans:300,300italic,400,400italic,600,600italic%7CNoto+Serif:400,400italic,700,700italic%7CDroid+Sans+Mono:400,700"; */
14 html{font-family:sans-serif;-webkit-text-size-adjust:
100%}
16 a:focus{outline:thin dotted}
17 a:active,a:hover{outline:
0}
18 h1{font-size:
2em;margin:
.67em
0}
19 b,strong{font-weight:bold}
21 abbr[title]{cursor:help;border-bottom:
1px dotted #dddddf;text-decoration:none}
22 dfn{font-style:italic}
24 mark{background:#ff0;color:#
000}
25 code,kbd,pre,samp{font-family:monospace;font-size:
1em}
26 pre{white-space:pre-wrap}
27 q{quotes:
"\201C" "\201D" "\2018" "\2019"}
29 sub,sup{font-size:
75%;line-height:
0;position:relative;vertical-align:baseline}
33 svg:not(:root){overflow:hidden}
35 audio,video{display:inline-block}
36 audio:not([controls]){display:none;height:
0}
37 fieldset{border:
1px solid silver;margin:
0 2px;padding:
.35em
.625em
.75em}
38 legend{border:
0;padding:
0}
39 button,input,select,textarea{font-family:inherit;font-size:
100%;margin:
0}
40 button,input{line-height:normal}
41 button,select{text-transform:none}
42 button,html input[type=button],input[type=reset],input[type=submit]{-webkit-appearance:button;cursor:pointer}
43 button[disabled],html input[disabled]{cursor:default}
44 input[type=checkbox],input[type=radio]{padding:
0}
45 button::-moz-focus-inner,input::-moz-focus-inner{border:
0;padding:
0}
46 textarea{overflow:auto;vertical-align:top}
47 table{border-collapse:collapse;border-spacing:
0}
48 *,::before,::after{box-sizing:border-box}
49 html,body{font-size:
100%}
50 body{background:#fff;color:rgba(
0,
0,
0,
.8);padding:
0;margin:
0;font-family:
"Noto Serif",
"DejaVu Serif",serif;line-height:
1;position:relative;cursor:auto;-moz-tab-size:
4;-o-tab-size:
4;tab-size:
4;word-wrap:anywhere;-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}
51 a:hover{cursor:pointer}
52 img,object,embed{max-width:
100%;height:auto}
53 object,embed{height:
100%}
54 img{-ms-interpolation-mode:bicubic}
55 .left{float:left!important}
56 .right{float:right!important}
57 .text-left{text-align:left!important}
58 .text-right{text-align:right!important}
59 .text-center{text-align:center!important}
60 .text-justify{text-align:justify!important}
62 img,object,svg{display:inline-block;vertical-align:middle}
63 textarea{height:auto;min-height:
50px}
65 .subheader,.admonitionblock td.content
>.title,.audioblock
>.title,.exampleblock
>.title,.imageblock
>.title,.listingblock
>.title,.literalblock
>.title,.stemblock
>.title,.openblock
>.title,.paragraph
>.title,.quoteblock
>.title,table.tableblock
>.title,.verseblock
>.title,.videoblock
>.title,.dlist
>.title,.olist
>.title,.ulist
>.title,.qlist
>.title,.hdlist
>.title{line-height:
1.45;color:#
7a2518;font-weight:
400;margin-top:
0;margin-bottom:
.25em}
66 div,dl,dt,dd,ul,ol,li,h1,h2,h3,#toctitle,.sidebarblock
>.content
>.title,h4,h5,h6,pre,form,p,blockquote,th,td{margin:
0;padding:
0}
67 a{color:#
2156a5;text-decoration:underline;line-height:inherit}
68 a:hover,a:focus{color:#
1d4b8f}
70 p{line-height:
1.6;margin-bottom:
1.25em;text-rendering:optimizeLegibility}
71 p aside{font-size:
.875em;line-height:
1.35;font-style:italic}
72 h1,h2,h3,#toctitle,.sidebarblock
>.content
>.title,h4,h5,h6{font-family:
"Open Sans",
"DejaVu Sans",sans-serif;font-weight:
300;font-style:normal;color:#ba3925;text-rendering:optimizeLegibility;margin-top:
1em;margin-bottom:
.5em;line-height:
1.0125em}
73 h1 small,h2 small,h3 small,#toctitle small,.sidebarblock
>.content
>.title small,h4 small,h5 small,h6 small{font-size:
60%;color:#e99b8f;line-height:
0}
75 h2{font-size:
1.6875em}
76 h3,#toctitle,.sidebarblock
>.content
>.title{font-size:
1.375em}
77 h4,h5{font-size:
1.125em}
79 hr{border:solid #dddddf;border-width:
1px
0 0;clear:both;margin:
1.25em
0 1.1875em}
80 em,i{font-style:italic;line-height:inherit}
81 strong,b{font-weight:bold;line-height:inherit}
82 small{font-size:
60%;line-height:inherit}
83 code{font-family:
"Droid Sans Mono",
"DejaVu Sans Mono",monospace;font-weight:
400;color:rgba(
0,
0,
0,
.9)}
84 ul,ol,dl{line-height:
1.6;margin-bottom:
1.25em;list-style-position:outside;font-family:inherit}
85 ul,ol{margin-left:
1.5em}
86 ul li ul,ul li ol{margin-left:
1.25em;margin-bottom:
0}
87 ul.circle{list-style-type:circle}
88 ul.disc{list-style-type:disc}
89 ul.square{list-style-type:square}
90 ul.circle ul:not([class]),ul.disc ul:not([class]),ul.square ul:not([class]){list-style:inherit}
91 ol li ul,ol li ol{margin-left:
1.25em;margin-bottom:
0}
92 dl dt{margin-bottom:
.3125em;font-weight:bold}
93 dl dd{margin-bottom:
1.25em}
94 blockquote{margin:
0 0 1.25em;padding:
.5625em
1.25em
0 1.1875em;border-left:
1px solid #ddd}
95 blockquote,blockquote p{line-height:
1.6;color:rgba(
0,
0,
0,
.85)}
96 @media screen and (min-width:
768px){h1,h2,h3,#toctitle,.sidebarblock
>.content
>.title,h4,h5,h6{line-height:
1.2}
98 h2{font-size:
2.3125em}
99 h3,#toctitle,.sidebarblock
>.content
>.title{font-size:
1.6875em}
100 h4{font-size:
1.4375em}}
101 table{background:#fff;margin-bottom:
1.25em;border:
1px solid #dedede;word-wrap:normal}
102 table thead,table tfoot{background:#f7f8f7}
103 table thead tr th,table thead tr td,table tfoot tr th,table tfoot tr td{padding:
.5em
.625em
.625em;font-size:inherit;color:rgba(
0,
0,
0,
.8);text-align:left}
104 table tr th,table tr td{padding:
.5625em
.625em;font-size:inherit;color:rgba(
0,
0,
0,
.8)}
105 table tr.even,table tr.alt{background:#f8f8f7}
106 table thead tr th,table tfoot tr th,table tbody tr td,table tr td,table tfoot tr td{line-height:
1.6}
107 h1,h2,h3,#toctitle,.sidebarblock
>.content
>.title,h4,h5,h6{line-height:
1.2;word-spacing:-
.05em}
108 h1 strong,h2 strong,h3 strong,#toctitle strong,.sidebarblock
>.content
>.title strong,h4 strong,h5 strong,h6 strong{font-weight:
400}
109 .center{margin-left:auto;margin-right:auto}
111 .clearfix::before,.clearfix::after,.float-group::before,.float-group::after{content:
" ";display:table}
112 .clearfix::after,.float-group::after{clear:both}
113 :not(pre).nobreak{word-wrap:normal}
114 :not(pre).nowrap{white-space:nowrap}
115 :not(pre).pre-wrap{white-space:pre-wrap}
116 :not(pre):not([class^=L])
>code{font-size:
.9375em;font-style:normal!important;letter-spacing:
0;padding:
.1em
.5ex;word-spacing:-
.15em;background:#f7f7f8;border-radius:
4px;line-height:
1.45;text-rendering:optimizeSpeed}
117 pre{color:rgba(
0,
0,
0,
.9);font-family:
"Droid Sans Mono",
"DejaVu Sans Mono",monospace;line-height:
1.45;text-rendering:optimizeSpeed}
118 pre code,pre pre{color:inherit;font-size:inherit;line-height:inherit}
119 pre
>code{display:block}
120 pre.nowrap,pre.nowrap pre{white-space:pre;word-wrap:normal}
121 em em{font-style:normal}
122 strong strong{font-weight:
400}
123 .keyseq{color:rgba(
51,
51,
51,
.8)}
124 kbd{font-family:
"Droid Sans Mono",
"DejaVu Sans Mono",monospace;display:inline-block;color:rgba(
0,
0,
0,
.8);font-size:
.65em;line-height:
1.45;background:#f7f7f7;border:
1px solid #ccc;border-radius:
3px;box-shadow:
0 1px
0 rgba(
0,
0,
0,
.2),inset
0 0 0 .1em #fff;margin:
0 .15em;padding:
.2em
.5em;vertical-align:middle;position:relative;top:-
.1em;white-space:nowrap}
125 .keyseq kbd:first-child{margin-left:
0}
126 .keyseq kbd:last-child{margin-right:
0}
127 .menuseq,.menuref{color:#
000}
128 .menuseq b:not(.caret),.menuref{font-weight:inherit}
129 .menuseq{word-spacing:-
.02em}
130 .menuseq b.caret{font-size:
1.25em;line-height:
.8}
131 .menuseq i.caret{font-weight:bold;text-align:center;width:
.45em}
132 b.button::before,b.button::after{position:relative;top:-
1px;font-weight:
400}
133 b.button::before{content:
"[";padding:
0 3px
0 2px}
134 b.button::after{content:
"]";padding:
0 2px
0 3px}
135 p a
>code:hover{color:rgba(
0,
0,
0,
.9)}
136 #header,#content,#footnotes,#footer{width:
100%;margin:
0 auto;max-width:
62.5em;*zoom:
1;position:relative;padding-left:
.9375em;padding-right:
.9375em}
137 #header::before,#header::after,#content::before,#content::after,#footnotes::before,#footnotes::after,#footer::before,#footer::after{content:
" ";display:table}
138 #header::after,#content::after,#footnotes::after,#footer::after{clear:both}
139 #content{margin-top:
1.25em}
140 #content::before{content:none}
141 #header
>h1:first-child{color:rgba(
0,
0,
0,
.85);margin-top:
2.25rem;margin-bottom:
0}
142 #header
>h1:first-child+#toc{margin-top:
8px;border-top:
1px solid #dddddf}
143 #header
>h1:only-child,body.toc2 #header
>h1:nth-last-child(
2){border-bottom:
1px solid #dddddf;padding-bottom:
8px}
144 #header .details{border-bottom:
1px solid #dddddf;line-height:
1.45;padding-top:
.25em;padding-bottom:
.25em;padding-left:
.25em;color:rgba(
0,
0,
0,
.6);display:flex;flex-flow:row wrap}
145 #header .details span:first-child{margin-left:-
.125em}
146 #header .details span.email a{color:rgba(
0,
0,
0,
.85)}
147 #header .details br{display:none}
148 #header .details br+span::before{content:
"\00a0\2013\00a0"}
149 #header .details br+span.author::before{content:
"\00a0\22c5\00a0";color:rgba(
0,
0,
0,
.85)}
150 #header .details br+span#revremark::before{content:
"\00a0|\00a0"}
151 #header #revnumber{text-transform:capitalize}
152 #header #revnumber::after{content:
"\00a0"}
153 #content
>h1:first-child:not([class]){color:rgba(
0,
0,
0,
.85);border-bottom:
1px solid #dddddf;padding-bottom:
8px;margin-top:
0;padding-top:
1rem;margin-bottom:
1.25rem}
154 #toc{border-bottom:
1px solid #e7e7e9;padding-bottom:
.5em}
155 #toc
>ul{margin-left:
.125em}
156 #toc ul.sectlevel0
>li
>a{font-style:italic}
157 #toc ul.sectlevel0 ul.sectlevel1{margin:
.5em
0}
158 #toc ul{font-family:
"Open Sans",
"DejaVu Sans",sans-serif;list-style-type:none}
159 #toc li{line-height:
1.3334;margin-top:
.3334em}
160 #toc a{text-decoration:none}
161 #toc a:active{text-decoration:underline}
162 #toctitle{color:#
7a2518;font-size:
1.2em}
163 @media screen and (min-width:
768px){#toctitle{font-size:
1.375em}
164 body.toc2{padding-left:
15em;padding-right:
0}
165 #toc.toc2{margin-top:
0!important;background:#f8f8f7;position:fixed;width:
15em;left:
0;top:
0;border-right:
1px solid #e7e7e9;border-top-width:
0!important;border-bottom-width:
0!important;z-index:
1000;padding:
1.25em
1em;height:
100%;overflow:auto}
166 #toc.toc2 #toctitle{margin-top:
0;margin-bottom:
.8rem;font-size:
1.2em}
167 #toc.toc2
>ul{font-size:
.9em;margin-bottom:
0}
168 #toc.toc2 ul ul{margin-left:
0;padding-left:
1em}
169 #toc.toc2 ul.sectlevel0 ul.sectlevel1{padding-left:
0;margin-top:
.5em;margin-bottom:
.5em}
170 body.toc2.toc-right{padding-left:
0;padding-right:
15em}
171 body.toc2.toc-right #toc.toc2{border-right-width:
0;border-left:
1px solid #e7e7e9;left:auto;right:
0}}
172 @media screen and (min-width:
1280px){body.toc2{padding-left:
20em;padding-right:
0}
173 #toc.toc2{width:
20em}
174 #toc.toc2 #toctitle{font-size:
1.375em}
175 #toc.toc2
>ul{font-size:
.95em}
176 #toc.toc2 ul ul{padding-left:
1.25em}
177 body.toc2.toc-right{padding-left:
0;padding-right:
20em}}
178 #content #toc{border:
1px solid #e0e0dc;margin-bottom:
1.25em;padding:
1.25em;background:#f8f8f7;border-radius:
4px}
179 #content #toc
>:first-child{margin-top:
0}
180 #content #toc
>:last-child{margin-bottom:
0}
181 #footer{max-width:none;background:rgba(
0,
0,
0,
.8);padding:
1.25em}
182 #footer-text{color:hsla(
0,
0%,
100%,
.8);line-height:
1.44}
183 #content{margin-bottom:
.625em}
184 .sect1{padding-bottom:
.625em}
185 @media screen and (min-width:
768px){#content{margin-bottom:
1.25em}
186 .sect1{padding-bottom:
1.25em}}
187 .sect1:last-child{padding-bottom:
0}
188 .sect1+.sect1{border-top:
1px solid #e7e7e9}
189 #content h1
>a.anchor,h2
>a.anchor,h3
>a.anchor,#toctitle
>a.anchor,.sidebarblock
>.content
>.title
>a.anchor,h4
>a.anchor,h5
>a.anchor,h6
>a.anchor{position:absolute;z-index:
1001;width:
1.5ex;margin-left:-
1.5ex;display:block;text-decoration:none!important;visibility:hidden;text-align:center;font-weight:
400}
190 #content h1
>a.anchor::before,h2
>a.anchor::before,h3
>a.anchor::before,#toctitle
>a.anchor::before,.sidebarblock
>.content
>.title
>a.anchor::before,h4
>a.anchor::before,h5
>a.anchor::before,h6
>a.anchor::before{content:
"\00A7";font-size:
.85em;display:block;padding-top:
.1em}
191 #content h1:hover
>a.anchor,#content h1
>a.anchor:hover,h2:hover
>a.anchor,h2
>a.anchor:hover,h3:hover
>a.anchor,#toctitle:hover
>a.anchor,.sidebarblock
>.content
>.title:hover
>a.anchor,h3
>a.anchor:hover,#toctitle
>a.anchor:hover,.sidebarblock
>.content
>.title
>a.anchor:hover,h4:hover
>a.anchor,h4
>a.anchor:hover,h5:hover
>a.anchor,h5
>a.anchor:hover,h6:hover
>a.anchor,h6
>a.anchor:hover{visibility:visible}
192 #content h1
>a.link,h2
>a.link,h3
>a.link,#toctitle
>a.link,.sidebarblock
>.content
>.title
>a.link,h4
>a.link,h5
>a.link,h6
>a.link{color:#ba3925;text-decoration:none}
193 #content h1
>a.link:hover,h2
>a.link:hover,h3
>a.link:hover,#toctitle
>a.link:hover,.sidebarblock
>.content
>.title
>a.link:hover,h4
>a.link:hover,h5
>a.link:hover,h6
>a.link:hover{color:#a53221}
194 details,.audioblock,.imageblock,.literalblock,.listingblock,.stemblock,.videoblock{margin-bottom:
1.25em}
195 details{margin-left:
1.25rem}
196 details
>summary{cursor:pointer;display:block;position:relative;line-height:
1.6;margin-bottom:
.625rem;outline:none;-webkit-tap-highlight-color:transparent}
197 details
>summary::-webkit-details-marker{display:none}
198 details
>summary::before{content:
"";border:solid transparent;border-left:solid;border-width:
.3em
0 .3em
.5em;position:absolute;top:
.5em;left:-
1.25rem;transform:translateX(
15%)}
199 details[open]
>summary::before{border:solid transparent;border-top:solid;border-width:
.5em
.3em
0;transform:translateY(
15%)}
200 details
>summary::after{content:
"";width:
1.25rem;height:
1em;position:absolute;top:
.3em;left:-
1.25rem}
201 .admonitionblock td.content
>.title,.audioblock
>.title,.exampleblock
>.title,.imageblock
>.title,.listingblock
>.title,.literalblock
>.title,.stemblock
>.title,.openblock
>.title,.paragraph
>.title,.quoteblock
>.title,table.tableblock
>.title,.verseblock
>.title,.videoblock
>.title,.dlist
>.title,.olist
>.title,.ulist
>.title,.qlist
>.title,.hdlist
>.title{text-rendering:optimizeLegibility;text-align:left;font-family:
"Noto Serif",
"DejaVu Serif",serif;font-size:
1rem;font-style:italic}
202 table.tableblock.fit-content
>caption.title{white-space:nowrap;width:
0}
203 .paragraph.lead
>p,#preamble
>.sectionbody
>[class=paragraph]:first-of-type p{font-size:
1.21875em;line-height:
1.6;color:rgba(
0,
0,
0,
.85)}
204 .admonitionblock
>table{border-collapse:separate;border:
0;background:none;width:
100%}
205 .admonitionblock
>table td.icon{text-align:center;width:
80px}
206 .admonitionblock
>table td.icon img{max-width:none}
207 .admonitionblock
>table td.icon .title{font-weight:bold;font-family:
"Open Sans",
"DejaVu Sans",sans-serif;text-transform:uppercase}
208 .admonitionblock
>table td.content{padding-left:
1.125em;padding-right:
1.25em;border-left:
1px solid #dddddf;color:rgba(
0,
0,
0,
.6);word-wrap:anywhere}
209 .admonitionblock
>table td.content
>:last-child
>:last-child{margin-bottom:
0}
210 .exampleblock
>.content{border:
1px solid #e6e6e6;margin-bottom:
1.25em;padding:
1.25em;background:#fff;border-radius:
4px}
211 .sidebarblock{border:
1px solid #dbdbd6;margin-bottom:
1.25em;padding:
1.25em;background:#f3f3f2;border-radius:
4px}
212 .sidebarblock
>.content
>.title{color:#
7a2518;margin-top:
0;text-align:center}
213 .exampleblock
>.content
>:first-child,.sidebarblock
>.content
>:first-child{margin-top:
0}
214 .exampleblock
>.content
>:last-child,.exampleblock
>.content
>:last-child
>:last-child,.exampleblock
>.content .olist
>ol
>li:last-child
>:last-child,.exampleblock
>.content .ulist
>ul
>li:last-child
>:last-child,.exampleblock
>.content .qlist
>ol
>li:last-child
>:last-child,.sidebarblock
>.content
>:last-child,.sidebarblock
>.content
>:last-child
>:last-child,.sidebarblock
>.content .olist
>ol
>li:last-child
>:last-child,.sidebarblock
>.content .ulist
>ul
>li:last-child
>:last-child,.sidebarblock
>.content .qlist
>ol
>li:last-child
>:last-child{margin-bottom:
0}
215 .literalblock pre,.listingblock
>.content
>pre{border-radius:
4px;overflow-x:auto;padding:
1em;font-size:
.8125em}
216 @media screen and (min-width:
768px){.literalblock pre,.listingblock
>.content
>pre{font-size:
.90625em}}
217 @media screen and (min-width:
1280px){.literalblock pre,.listingblock
>.content
>pre{font-size:
1em}}
218 .literalblock pre,.listingblock
>.content
>pre:not(.highlight),.listingblock
>.content
>pre[class=highlight],.listingblock
>.content
>pre[class^=
"highlight "]{background:#f7f7f8}
219 .literalblock.output pre{color:#f7f7f8;background:rgba(
0,
0,
0,
.9)}
220 .listingblock
>.content{position:relative}
221 .listingblock code[data-lang]::before{display:none;content:attr(data-lang);position:absolute;font-size:
.75em;top:
.425rem;right:
.5rem;line-height:
1;text-transform:uppercase;color:inherit;opacity:
.5}
222 .listingblock:hover code[data-lang]::before{display:block}
223 .listingblock.terminal pre .command::before{content:attr(data-prompt);padding-right:
.5em;color:inherit;opacity:
.5}
224 .listingblock.terminal pre .command:not([data-prompt])::before{content:
"$"}
225 .listingblock pre.highlightjs{padding:
0}
226 .listingblock pre.highlightjs
>code{padding:
1em;border-radius:
4px}
227 .listingblock pre.prettyprint{border-width:
0}
228 .prettyprint{background:#f7f7f8}
229 pre.prettyprint .linenums{line-height:
1.45;margin-left:
2em}
230 pre.prettyprint li{background:none;list-style-type:inherit;padding-left:
0}
231 pre.prettyprint li code[data-lang]::before{opacity:
1}
232 pre.prettyprint li:not(:first-child) code[data-lang]::before{display:none}
233 table.linenotable{border-collapse:separate;border:
0;margin-bottom:
0;background:none}
234 table.linenotable td[class]{color:inherit;vertical-align:top;padding:
0;line-height:inherit;white-space:normal}
235 table.linenotable td.code{padding-left:
.75em}
236 table.linenotable td.linenos,pre.pygments .linenos{border-right:
1px solid;opacity:
.35;padding-right:
.5em;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}
237 pre.pygments span.linenos{display:inline-block;margin-right:
.75em}
238 .quoteblock{margin:
0 1em
1.25em
1.5em;display:table}
239 .quoteblock:not(.excerpt)
>.title{margin-left:-
1.5em;margin-bottom:
.75em}
240 .quoteblock blockquote,.quoteblock p{color:rgba(
0,
0,
0,
.85);font-size:
1.15rem;line-height:
1.75;word-spacing:
.1em;letter-spacing:
0;font-style:italic;text-align:justify}
241 .quoteblock blockquote{margin:
0;padding:
0;border:
0}
242 .quoteblock blockquote::before{content:
"\201c";float:left;font-size:
2.75em;font-weight:bold;line-height:
.6em;margin-left:-
.6em;color:#
7a2518;text-shadow:
0 1px
2px rgba(
0,
0,
0,
.1)}
243 .quoteblock blockquote
>.paragraph:last-child p{margin-bottom:
0}
244 .quoteblock .attribution{margin-top:
.75em;margin-right:
.5ex;text-align:right}
245 .verseblock{margin:
0 1em
1.25em}
246 .verseblock pre{font-family:
"Open Sans",
"DejaVu Sans",sans-serif;font-size:
1.15rem;color:rgba(
0,
0,
0,
.85);font-weight:
300;text-rendering:optimizeLegibility}
247 .verseblock pre strong{font-weight:
400}
248 .verseblock .attribution{margin-top:
1.25rem;margin-left:
.5ex}
249 .quoteblock .attribution,.verseblock .attribution{font-size:
.9375em;line-height:
1.45;font-style:italic}
250 .quoteblock .attribution br,.verseblock .attribution br{display:none}
251 .quoteblock .attribution cite,.verseblock .attribution cite{display:block;letter-spacing:-
.025em;color:rgba(
0,
0,
0,
.6)}
252 .quoteblock.abstract blockquote::before,.quoteblock.excerpt blockquote::before,.quoteblock .quoteblock blockquote::before{display:none}
253 .quoteblock.abstract blockquote,.quoteblock.abstract p,.quoteblock.excerpt blockquote,.quoteblock.excerpt p,.quoteblock .quoteblock blockquote,.quoteblock .quoteblock p{line-height:
1.6;word-spacing:
0}
254 .quoteblock.abstract{margin:
0 1em
1.25em;display:block}
255 .quoteblock.abstract
>.title{margin:
0 0 .375em;font-size:
1.15em;text-align:center}
256 .quoteblock.excerpt
>blockquote,.quoteblock .quoteblock{padding:
0 0 .25em
1em;border-left:
.25em solid #dddddf}
257 .quoteblock.excerpt,.quoteblock .quoteblock{margin-left:
0}
258 .quoteblock.excerpt blockquote,.quoteblock.excerpt p,.quoteblock .quoteblock blockquote,.quoteblock .quoteblock p{color:inherit;font-size:
1.0625rem}
259 .quoteblock.excerpt .attribution,.quoteblock .quoteblock .attribution{color:inherit;font-size:
.85rem;text-align:left;margin-right:
0}
260 p.tableblock:last-child{margin-bottom:
0}
261 td.tableblock
>.content{margin-bottom:
1.25em;word-wrap:anywhere}
262 td.tableblock
>.content
>:last-child{margin-bottom:-
1.25em}
263 table.tableblock,th.tableblock,td.tableblock{border:
0 solid #dedede}
264 table.grid-all
>*
>tr
>*{border-width:
1px}
265 table.grid-cols
>*
>tr
>*{border-width:
0 1px}
266 table.grid-rows
>*
>tr
>*{border-width:
1px
0}
267 table.frame-all{border-width:
1px}
268 table.frame-ends{border-width:
1px
0}
269 table.frame-sides{border-width:
0 1px}
270 table.frame-none
>colgroup+*
>:first-child
>*,table.frame-sides
>colgroup+*
>:first-child
>*{border-top-width:
0}
271 table.frame-none
>:last-child
>:last-child
>*,table.frame-sides
>:last-child
>:last-child
>*{border-bottom-width:
0}
272 table.frame-none
>*
>tr
>:first-child,table.frame-ends
>*
>tr
>:first-child{border-left-width:
0}
273 table.frame-none
>*
>tr
>:last-child,table.frame-ends
>*
>tr
>:last-child{border-right-width:
0}
274 table.stripes-all
>*
>tr,table.stripes-odd
>*
>tr:nth-of-type(odd),table.stripes-even
>*
>tr:nth-of-type(even),table.stripes-hover
>*
>tr:hover{background:#f8f8f7}
275 th.halign-left,td.halign-left{text-align:left}
276 th.halign-right,td.halign-right{text-align:right}
277 th.halign-center,td.halign-center{text-align:center}
278 th.valign-top,td.valign-top{vertical-align:top}
279 th.valign-bottom,td.valign-bottom{vertical-align:bottom}
280 th.valign-middle,td.valign-middle{vertical-align:middle}
281 table thead th,table tfoot th{font-weight:bold}
282 tbody tr th{background:#f7f8f7}
283 tbody tr th,tbody tr th p,tfoot tr th,tfoot tr th p{color:rgba(
0,
0,
0,
.8);font-weight:bold}
284 p.tableblock
>code:only-child{background:none;padding:
0}
285 p.tableblock{font-size:
1em}
286 ol{margin-left:
1.75em}
287 ul li ol{margin-left:
1.5em}
288 dl dd{margin-left:
1.125em}
289 dl dd:last-child,dl dd:last-child
>:last-child{margin-bottom:
0}
290 li p,ul dd,ol dd,.olist .olist,.ulist .ulist,.ulist .olist,.olist .ulist{margin-bottom:
.625em}
291 ul.checklist,ul.none,ol.none,ul.no-bullet,ol.no-bullet,ol.unnumbered,ul.unstyled,ol.unstyled{list-style-type:none}
292 ul.no-bullet,ol.no-bullet,ol.unnumbered{margin-left:
.625em}
293 ul.unstyled,ol.unstyled{margin-left:
0}
294 li
>p:empty:only-child::before{content:
"";display:inline-block}
295 ul.checklist
>li
>p:first-child{margin-left:-
1em}
296 ul.checklist
>li
>p:first-child
>.fa-square-o:first-child,ul.checklist
>li
>p:first-child
>.fa-check-square-o:first-child{width:
1.25em;font-size:
.8em;position:relative;bottom:
.125em}
297 ul.checklist
>li
>p:first-child
>input[type=checkbox]:first-child{margin-right:
.25em}
298 ul.inline{display:flex;flex-flow:row wrap;list-style:none;margin:
0 0 .625em -
1.25em}
299 ul.inline
>li{margin-left:
1.25em}
300 .unstyled dl dt{font-weight:
400;font-style:normal}
301 ol.arabic{list-style-type:decimal}
302 ol.decimal{list-style-type:decimal-leading-zero}
303 ol.loweralpha{list-style-type:lower-alpha}
304 ol.upperalpha{list-style-type:upper-alpha}
305 ol.lowerroman{list-style-type:lower-roman}
306 ol.upperroman{list-style-type:upper-roman}
307 ol.lowergreek{list-style-type:lower-greek}
308 .hdlist
>table,.colist
>table{border:
0;background:none}
309 .hdlist
>table
>tbody
>tr,.colist
>table
>tbody
>tr{background:none}
310 td.hdlist1,td.hdlist2{vertical-align:top;padding:
0 .625em}
311 td.hdlist1{font-weight:bold;padding-bottom:
1.25em}
312 td.hdlist2{word-wrap:anywhere}
313 .literalblock+.colist,.listingblock+.colist{margin-top:-
.5em}
314 .colist td:not([class]):first-child{padding:
.4em
.75em
0;line-height:
1;vertical-align:top}
315 .colist td:not([class]):first-child img{max-width:none}
316 .colist td:not([class]):last-child{padding:
.25em
0}
317 .thumb,.th{line-height:
0;display:inline-block;border:
4px solid #fff;box-shadow:
0 0 0 1px #ddd}
318 .imageblock.left{margin:
.25em
.625em
1.25em
0}
319 .imageblock.right{margin:
.25em
0 1.25em
.625em}
320 .imageblock
>.title{margin-bottom:
0}
321 .imageblock.thumb,.imageblock.th{border-width:
6px}
322 .imageblock.thumb
>.title,.imageblock.th
>.title{padding:
0 .125em}
323 .image.left,.image.right{margin-top:
.25em;margin-bottom:
.25em;display:inline-block;line-height:
0}
324 .image.left{margin-right:
.625em}
325 .image.right{margin-left:
.625em}
326 a.image{text-decoration:none;display:inline-block}
327 a.image object{pointer-events:none}
328 sup.footnote,sup.footnoteref{font-size:
.875em;position:static;vertical-align:super}
329 sup.footnote a,sup.footnoteref a{text-decoration:none}
330 sup.footnote a:active,sup.footnoteref a:active{text-decoration:underline}
331 #footnotes{padding-top:
.75em;padding-bottom:
.75em;margin-bottom:
.625em}
332 #footnotes hr{width:
20%;min-width:
6.25em;margin:-
.25em
0 .75em;border-width:
1px
0 0}
333 #footnotes .footnote{padding:
0 .375em
0 .225em;line-height:
1.3334;font-size:
.875em;margin-left:
1.2em;margin-bottom:
.2em}
334 #footnotes .footnote a:first-of-type{font-weight:bold;text-decoration:none;margin-left:-
1.05em}
335 #footnotes .footnote:last-of-type{margin-bottom:
0}
336 #content #footnotes{margin-top:-
.625em;margin-bottom:
0;padding:
.75em
0}
337 div.unbreakable{page-break-inside:avoid}
338 .big{font-size:larger}
339 .small{font-size:smaller}
340 .underline{text-decoration:underline}
341 .overline{text-decoration:overline}
342 .line-through{text-decoration:line-through}
344 .aqua-background{background:#
00fafa}
346 .black-background{background:#
000}
348 .blue-background{background:#
0000fa}
349 .fuchsia{color:#bf00bf}
350 .fuchsia-background{background:#fa00fa}
352 .gray-background{background:#
7d7d7d}
353 .green{color:#
006000}
354 .green-background{background:#
007d00}
356 .lime-background{background:#
00fa00}
357 .maroon{color:#
600000}
358 .maroon-background{background:#
7d0000}
360 .navy-background{background:#
00007d}
361 .olive{color:#
606000}
362 .olive-background{background:#
7d7d00}
363 .purple{color:#
600060}
364 .purple-background{background:#
7d007d}
366 .red-background{background:#fa0000}
367 .silver{color:#
909090}
368 .silver-background{background:#bcbcbc}
370 .teal-background{background:#
007d7d}
371 .white{color:#bfbfbf}
372 .white-background{background:#fafafa}
373 .yellow{color:#bfbf00}
374 .yellow-background{background:#fafa00}
375 span.icon
>.fa{cursor:default}
376 a span.icon
>.fa{cursor:inherit}
377 .admonitionblock td.icon [class^=
"fa icon-"]{font-size:
2.5em;text-shadow:
1px
1px
2px rgba(
0,
0,
0,
.5);cursor:default}
378 .admonitionblock td.icon .icon-note::before{content:
"\f05a";color:#
19407c}
379 .admonitionblock td.icon .icon-tip::before{content:
"\f0eb";text-shadow:
1px
1px
2px rgba(
155,
155,
0,
.8);color:#
111}
380 .admonitionblock td.icon .icon-warning::before{content:
"\f071";color:#bf6900}
381 .admonitionblock td.icon .icon-caution::before{content:
"\f06d";color:#bf3400}
382 .admonitionblock td.icon .icon-important::before{content:
"\f06a";color:#bf0000}
383 .conum[data-value]{display:inline-block;color:#fff!important;background:rgba(
0,
0,
0,
.8);border-radius:
50%;text-align:center;font-size:
.75em;width:
1.67em;height:
1.67em;line-height:
1.67em;font-family:
"Open Sans",
"DejaVu Sans",sans-serif;font-style:normal;font-weight:bold}
384 .conum[data-value] *{color:#fff!important}
385 .conum[data-value]+b{display:none}
386 .conum[data-value]::after{content:attr(data-value)}
387 pre .conum[data-value]{position:relative;top:-
.125em}
388 b.conum *{color:inherit!important}
389 .conum:not([data-value]):empty{display:none}
390 dt,th.tableblock,td.content,div.footnote{text-rendering:optimizeLegibility}
391 h1,h2,p,td.content,span.alt,summary{letter-spacing:-
.01em}
392 p strong,td.content strong,div.footnote strong{letter-spacing:-
.005em}
393 p,blockquote,dt,td.content,td.hdlist1,span.alt,summary{font-size:
1.0625rem}
394 p{margin-bottom:
1.25rem}
395 .sidebarblock p,.sidebarblock dt,.sidebarblock td.content,p.tableblock{font-size:
1em}
396 .exampleblock
>.content{background:#fffef7;border-color:#e0e0dc;box-shadow:
0 1px
4px #e0e0dc}
397 .print-only{display:none!important}
398 @page{margin:
1.25cm
.75cm}
399 @media print{*{box-shadow:none!important;text-shadow:none!important}
401 a{color:inherit!important;text-decoration:underline!important}
402 a.bare,a[href^=
"#"],a[href^=
"mailto:"]{text-decoration:none!important}
403 a[href^=
"http:"]:not(.bare)::after,a[href^=
"https:"]:not(.bare)::after{content:
"(" attr(href)
")";display:inline-block;font-size:
.875em;padding-left:
.25em}
404 abbr[title]{border-bottom:
1px dotted}
405 abbr[title]::after{content:
" (" attr(title)
")"}
406 pre,blockquote,tr,img,object,svg{page-break-inside:avoid}
407 thead{display:table-header-group}
409 p,blockquote,dt,td.content{font-size:
1em;orphans:
3;widows:
3}
410 h2,h3,#toctitle,.sidebarblock
>.content
>.title{page-break-after:avoid}
411 #header,#content,#footnotes,#footer{max-width:none}
412 #toc,.sidebarblock,.exampleblock
>.content{background:none!important}
413 #toc{border-bottom:
1px solid #dddddf!important;padding-bottom:
0!important}
414 body.book #header{text-align:center}
415 body.book #header
>h1:first-child{border:
0!important;margin:
2.5em
0 1em}
416 body.book #header .details{border:
0!important;display:block;padding:
0!important}
417 body.book #header .details span:first-child{margin-left:
0!important}
418 body.book #header .details br{display:block}
419 body.book #header .details br+span::before{content:none!important}
420 body.book #toc{border:
0!important;text-align:left!important;padding:
0!important;margin:
0!important}
421 body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1
>h2{page-break-before:always}
422 .listingblock code[data-lang]::before{display:block}
423 #footer{padding:
0 .9375em}
424 .hide-on-print{display:none!important}
425 .print-only{display:block!important}
426 .hide-for-print{display:none!important}
427 .show-for-print{display:inherit!important}}
428 @media amzn-kf8,print{#header
>h1:first-child{margin-top:
1.25rem}
429 .sect1{padding:
0!important}
430 .sect1+.sect1{border:
0}
431 #footer{background:none}
432 #footer-text{color:rgba(
0,
0,
0,
.6);font-size:
.9em}}
433 @media amzn-kf8{#header,#content,#footnotes,#footer{padding:
0}}
441 <body class=
"article">
443 <h1>My First Contribution to the Git Project
</h1>
444 <div class=
"details">
445 <span id=
"revdate">2024-
11-
16</span>
450 <h2 id=
"summary"><a class=
"anchor" href=
"#summary"></a>Summary
</h2>
451 <div class=
"sectionbody">
452 <div class=
"paragraph">
453 <p>This is a tutorial demonstrating the end-to-end workflow of creating a change to
454 the Git tree, sending it for review, and making changes based on comments.
</p>
457 <h3 id=
"prerequisites"><a class=
"anchor" href=
"#prerequisites"></a>Prerequisites
</h3>
458 <div class=
"paragraph">
459 <p>This tutorial assumes you
’re already fairly familiar with using Git to manage
460 source code. The Git workflow steps will largely remain unexplained.
</p>
464 <h3 id=
"related-reading"><a class=
"anchor" href=
"#related-reading"></a>Related Reading
</h3>
465 <div class=
"paragraph">
466 <p>This tutorial aims to summarize the following documents, but the reader may find
467 useful additional context:
</p>
472 <p><code>Documentation/SubmittingPatches
</code></p>
475 <p><code>Documentation/howto/new-command.txt
</code></p>
481 <h3 id=
"getting-help"><a class=
"anchor" href=
"#getting-help"></a>Getting Help
</h3>
482 <div class=
"paragraph">
483 <p>If you get stuck, you can seek help in the following places.
</p>
486 <h4 id=
"_gitvger_kernel_org"><a class=
"anchor" href=
"#_gitvger_kernel_org"></a><a href=
"mailto:git@vger.kernel.org">git@vger.kernel.org
</a></h4>
487 <div class=
"paragraph">
488 <p>This is the main Git project mailing list where code reviews, version
489 announcements, design discussions, and more take place. Those interested in
490 contributing are welcome to post questions here. The Git list requires
491 plain-text-only emails and prefers inline and bottom-posting when replying to
492 mail; you will be CC
’d in all replies to you. Optionally, you can subscribe to
493 the list by sending an email to
<<a href=
"mailto:git+subscribe@vger.kernel.org">git+subscribe@vger.kernel.org
</a>>
494 (see
<a href=
"https://subspace.kernel.org/subscribing.html" class=
"bare">https://subspace.kernel.org/subscribing.html
</a> for details).
495 The
<a href=
"https://lore.kernel.org/git">archive
</a> of this mailing list is
496 available to view in a browser.
</p>
500 <h4 id=
"_git_mentoringgooglegroups_com"><a class=
"anchor" href=
"#_git_mentoringgooglegroups_com"></a><a href=
"https://groups.google.com/forum/#!forum/git-mentoring">git-mentoring@googlegroups.com
</a></h4>
501 <div class=
"paragraph">
502 <p>This mailing list is targeted to new contributors and was created as a place to
503 post questions and receive answers outside of the public eye of the main list.
504 Veteran contributors who are especially interested in helping mentor newcomers
505 are present on the list. In order to avoid search indexers, group membership is
506 required to view messages; anyone can join and no approval is required.
</p>
510 <h4 id=
"_git_devel_on_libera_chat"><a class=
"anchor" href=
"#_git_devel_on_libera_chat"></a><a href=
"https://web.libera.chat/#git-devel">#git-devel
</a> on Libera Chat
</h4>
511 <div class=
"paragraph">
512 <p>This IRC channel is for conversations between Git contributors. If someone is
513 currently online and knows the answer to your question, you can receive help
514 in real time. Otherwise, you can read the
515 <a href=
"https://colabti.org/irclogger/irclogger_logs/git-devel">scrollback
</a> to see
516 whether someone answered you. IRC does not allow offline private messaging, so
517 if you try to private message someone and then log out of IRC, they cannot
518 respond to you. It
’s better to ask your questions in the channel so that you
519 can be answered if you disconnect and so that others can learn from the
527 <h2 id=
"getting-started"><a class=
"anchor" href=
"#getting-started"></a>Getting Started
</h2>
528 <div class=
"sectionbody">
530 <h3 id=
"cloning"><a class=
"anchor" href=
"#cloning"></a>Clone the Git Repository
</h3>
531 <div class=
"paragraph">
532 <p>Git is mirrored in a number of locations. Clone the repository from one of them;
533 <a href=
"https://git-scm.com/downloads" class=
"bare">https://git-scm.com/downloads
</a> suggests one of the best places to clone from is
534 the mirror on GitHub.
</p>
536 <div class=
"listingblock">
537 <div class=
"content">
538 <pre>$ git clone https://github.com/git/git git
544 <h3 id=
"dependencies"><a class=
"anchor" href=
"#dependencies"></a>Installing Dependencies
</h3>
545 <div class=
"paragraph">
546 <p>To build Git from source, you need to have a handful of dependencies installed
547 on your system. For a hint of what
’s needed, you can take a look at
548 <code>INSTALL
</code>, paying close attention to the section about Git
’s dependencies on
549 external programs and libraries. That document mentions a way to
"test-drive"
550 our freshly built Git without installing; that
’s the method we
’ll be using in
553 <div class=
"paragraph">
554 <p>Make sure that your environment has everything you need by building your brand
555 new clone of Git from the above step:
</p>
557 <div class=
"listingblock">
558 <div class=
"content">
562 <div class=
"admonitionblock note">
566 <div class=
"title">Note
</div>
569 The Git build is parallelizable.
<code>-j
</code># is not included above but you can
570 use it as you prefer, here and elsewhere.
577 <h3 id=
"identify-problem"><a class=
"anchor" href=
"#identify-problem"></a>Identify Problem to Solve
</h3>
578 <div class=
"paragraph">
579 <p>In this tutorial, we will add a new command,
<code>git
</code> <code>psuh
</code>, short for
“Pony Saying
580 ‘Um, Hello
”’ - a feature which has gone unimplemented despite a high frequency
581 of invocation during users' typical daily workflow.
</p>
583 <div class=
"paragraph">
584 <p>(We
’ve seen some other effort in this space with the implementation of popular
585 commands such as
<code>sl
</code>.)
</p>
589 <h3 id=
"setup-workspace"><a class=
"anchor" href=
"#setup-workspace"></a>Set Up Your Workspace
</h3>
590 <div class=
"paragraph">
591 <p>Let
’s start by making a development branch to work on our changes. Per
592 <code>Documentation/SubmittingPatches
</code>, since a brand new command is a new feature,
593 it
’s fine to base your work on
<code>master
</code>. However, in the future for bugfixes,
594 etc., you should check that document and base it on the appropriate branch.
</p>
596 <div class=
"paragraph">
597 <p>For the purposes of this document, we will base all our work on the
<code>master
</code>
598 branch of the upstream project. Create the
<code>psuh
</code> branch you will use for
599 development like so:
</p>
601 <div class=
"listingblock">
602 <div class=
"content">
603 <pre>$ git checkout -b psuh origin/master
</pre>
606 <div class=
"paragraph">
607 <p>We
’ll make a number of commits here in order to demonstrate how to send a topic
608 with multiple patches up for review simultaneously.
</p>
614 <h2 id=
"code-it-up"><a class=
"anchor" href=
"#code-it-up"></a>Code It Up!
</h2>
615 <div class=
"sectionbody">
616 <div class=
"admonitionblock note">
620 <div class=
"title">Note
</div>
623 A reference implementation can be found at
624 <a href=
"https://github.com/nasamuffin/git/tree/psuh" class=
"bare">https://github.com/nasamuffin/git/tree/psuh
</a>.
630 <h3 id=
"add-new-command"><a class=
"anchor" href=
"#add-new-command"></a>Adding a New Command
</h3>
631 <div class=
"paragraph">
632 <p>Lots of the subcommands are written as builtins, which means they are
633 implemented in C and compiled into the main
<code>git
</code> executable. Implementing the
634 very simple
<code>psuh
</code> command as a built-in will demonstrate the structure of the
635 codebase, the internal API, and the process of working together as a contributor
636 with the reviewers and maintainer to integrate this change into the system.
</p>
638 <div class=
"paragraph">
639 <p>Built-in subcommands are typically implemented in a function named
"cmd_"
640 followed by the name of the subcommand, in a source file named after the
641 subcommand and contained within
<code>builtin/
</code>. So it makes sense to implement your
642 command in
<code>builtin/psuh.c
</code>. Create that file, and within it, write the entry
643 point for your command in a function matching the style and signature:
</p>
645 <div class=
"listingblock">
646 <div class=
"content">
647 <pre>int cmd_psuh(int argc, const char **argv, const char *prefix)
</pre>
650 <div class=
"paragraph">
651 <p>We
’ll also need to add the declaration of psuh; open up
<code>builtin.h
</code>, find the
652 declaration for
<code>cmd_pull
</code>, and add a new line for
<code>psuh
</code> immediately before it,
653 in order to keep the declarations alphabetically sorted:
</p>
655 <div class=
"listingblock">
656 <div class=
"content">
657 <pre>int cmd_psuh(int argc, const char **argv, const char *prefix);
</pre>
660 <div class=
"paragraph">
661 <p>Be sure to #include
"builtin.<code>h</code>" in your
<code>psuh.c
</code>. You
’ll also need to
662 #include
"gettext.<code>h</code>" to use functions related to printing output text.
</p>
664 <div class=
"paragraph">
665 <p>Go ahead and add some throwaway printf to the
<code>cmd_psuh
</code> function. This is a
666 decent starting point as we can now add build rules and register the command.
</p>
668 <div class=
"admonitionblock note">
672 <div class=
"title">Note
</div>
675 Your throwaway text, as well as much of the text you will be adding over
676 the course of this tutorial, is user-facing. That means it needs to be
677 localizable. Take a look at
<code>po/README
</code> under
"Marking strings for translation".
678 Throughout the tutorial, we will mark strings for translation as necessary; you
679 should also do so when writing your user-facing commands in the future.
684 <div class=
"listingblock">
685 <div class=
"content">
686 <pre>int cmd_psuh(int argc, const char **argv, const char *prefix)
688 printf(_(
"Pony saying hello goes here.\n"));
693 <div class=
"paragraph">
694 <p>Let
’s try to build it. Open
<code>Makefile
</code>, find where
<code>builtin/pull.o
</code> is added
695 to
<code>BUILTIN_OBJS
</code>, and add
<code>builtin/psuh.o
</code> in the same way next to it in
696 alphabetical order. Once you
’ve done so, move to the top-level directory and
697 build simply with
<code>make
</code>. Also add the
<code>DEVELOPER=
1</code> variable to turn on
698 some additional warnings:
</p>
700 <div class=
"listingblock">
701 <div class=
"content">
702 <pre>$ echo DEVELOPER=
1 >config.mak
706 <div class=
"admonitionblock note">
710 <div class=
"title">Note
</div>
713 When you are developing the Git project, it
’s preferred that you use the
714 <code>DEVELOPER
</code> flag; if there
’s some reason it doesn
’t work for you, you can turn
715 it off, but it
’s a good idea to mention the problem to the mailing list.
720 <div class=
"paragraph">
721 <p>Great, now your new command builds happily on its own. But nobody invokes it.
722 Let
’s change that.
</p>
724 <div class=
"paragraph">
725 <p>The list of commands lives in
<code>git.c
</code>. We can register a new command by adding
726 a
<code>cmd_struct
</code> to the
<code>commands
</code>[] array.
<code>struct
</code> <code>cmd_struct
</code> takes a string
727 with the command name, a function pointer to the command implementation, and a
728 setup option flag. For now, let
’s keep mimicking
<code>push
</code>. Find the line where
729 <code>cmd_push
</code> is registered, copy it, and modify it for
<code>cmd_psuh
</code>, placing the new
730 line in alphabetical order (immediately before
<code>cmd_pull
</code>).
</p>
732 <div class=
"paragraph">
733 <p>The options are documented in
<code>builtin.h
</code> under
"Adding a new built-in." Since
734 we hope to print some data about the user
’s current workspace context later,
735 we need a Git directory, so choose
<code>RUN_SETUP
</code> as your only option.
</p>
737 <div class=
"paragraph">
738 <p>Go ahead and build again. You should see a clean build, so let
’s kick the tires
739 and see if it works. There
’s a binary you can use to test with in the
740 <code>bin-wrappers
</code> directory.
</p>
742 <div class=
"listingblock">
743 <div class=
"content">
744 <pre>$ ./bin-wrappers/git psuh
</pre>
747 <div class=
"paragraph">
748 <p>Check it out! You
’ve got a command! Nice work! Let
’s commit this.
</p>
750 <div class=
"paragraph">
751 <p><code>git
</code> <code>status
</code> reveals modified
<code>Makefile
</code>,
<code>builtin.h
</code>, and
<code>git.c
</code> as well as
752 untracked
<code>builtin/psuh.c
</code> and
<code>git-psuh
</code>. First, let
’s take care of the binary,
753 which should be ignored. Open .
<code>gitignore
</code> in your editor, find
<code>/git-pull
</code>, and
754 add an entry for your new command in alphabetical order:
</p>
756 <div class=
"listingblock">
757 <div class=
"content">
768 <div class=
"paragraph">
769 <p>Checking
<code>git
</code> <code>status
</code> again should show that
<code>git-psuh
</code> has been removed from
770 the untracked list and .
<code>gitignore
</code> has been added to the modified list. Now we
771 can stage and commit:
</p>
773 <div class=
"listingblock">
774 <div class=
"content">
775 <pre>$ git add Makefile builtin.h builtin/psuh.c git.c .gitignore
776 $ git commit -s
</pre>
779 <div class=
"paragraph">
780 <p>You will be presented with your editor in order to write a commit message. Start
781 the commit with a
50-column or less subject line, including the name of the
782 component you
’re working on, followed by a blank line (always required) and then
783 the body of your commit message, which should provide the bulk of the context.
784 Remember to be explicit and provide the
"Why" of your change, especially if it
785 couldn
’t easily be understood from your diff. When editing your commit message,
786 don
’t remove the
<code>Signed-off-by
</code> trailer which was added by
<code>-s
</code> above.
</p>
788 <div class=
"listingblock">
789 <div class=
"content">
790 <pre>psuh: add a built-in by popular demand
792 Internal metrics indicate this is a command many users expect to be
793 present. So here's an implementation to help drive customer
794 satisfaction and engagement: a pony which doubtfully greets the user,
795 or, a Pony Saying
"Um, Hello" (PSUH).
797 This commit message is intentionally formatted to
72 columns per line,
798 starts with a single line as
"commit message subject" that is written as
799 if to command the codebase to do something (add this, teach a command
800 that). The body of the message is designed to add information about the
801 commit that is not readily deduced from reading the associated diff,
802 such as answering the question
"why?".
804 Signed-off-by: A U Thor
<author@example.com
></pre>
807 <div class=
"paragraph">
808 <p>Go ahead and inspect your new commit with
<code>git
</code> <code>show
</code>.
"psuh:" indicates you
809 have modified mainly the
<code>psuh
</code> command. The subject line gives readers an idea
810 of what you
’ve changed. The sign-off line (
<code>-s
</code>) indicates that you agree to
811 the Developer
’s Certificate of Origin
1.1 (see the
812 <code>Documentation/SubmittingPatches
</code> [[dco]] header).
</p>
814 <div class=
"paragraph">
815 <p>For the remainder of the tutorial, the subject line only will be listed for the
816 sake of brevity. However, fully-fleshed example commit messages are available
817 on the reference implementation linked at the top of this document.
</p>
821 <h3 id=
"implementation"><a class=
"anchor" href=
"#implementation"></a>Implementation
</h3>
822 <div class=
"paragraph">
823 <p>It
’s probably useful to do at least something besides printing out a string.
824 Let
’s start by having a look at everything we get.
</p>
826 <div class=
"paragraph">
827 <p>Modify your
<code>cmd_psuh
</code> implementation to dump the args you
’re passed, keeping
828 existing
<code>printf
</code>() calls in place:
</p>
830 <div class=
"listingblock">
831 <div class=
"content">
836 printf(Q_(
"Your args (there is %d):\n",
837 "Your args (there are %d):\n",
840 for (i =
0; i
< argc; i++)
841 printf(
"%d: %s\n", i, argv[i]);
843 printf(_(
"Your current working directory:\n<top-level>%s%s\n"),
844 prefix ?
"/" :
"", prefix ? prefix :
"");
</pre>
847 <div class=
"paragraph">
848 <p>Build and try it. As you may expect, there
’s pretty much just whatever we give
849 on the command line, including the name of our command. (If
<code>prefix
</code> is empty
850 for you, try
<code>cd
</code> <code>Documentation/
</code> && <code>..
</code><code>/bin-wrappers/git
</code> <code>psuh
</code>). That
’s not so
851 helpful. So what other context can we get?
</p>
853 <div class=
"paragraph">
854 <p>Add a line to #include
"config.<code>h</code>". Then, add the following bits to the
857 <div class=
"listingblock">
858 <div class=
"content">
859 <pre> const char *cfg_name;
863 git_config(git_default_config, NULL);
864 if (git_config_get_string_tmp(
"user.name",
&cfg_name)
> 0)
865 printf(_(
"No name is found in config\n"));
867 printf(_(
"Your name: %s\n"), cfg_name);
</pre>
870 <div class=
"paragraph">
871 <p><code>git_config
</code>() will grab the configuration from config files known to Git and
872 apply standard precedence rules.
<code>git_config_get_string_tmp
</code>() will look up
873 a specific key (
"user.name") and give you the value. There are a number of
874 single-key lookup functions like this one; you can see them all (and more info
875 about how to use
<code>git_config
</code>()) in
<code>Documentation/technical/api-config.txt
</code>.
</p>
877 <div class=
"paragraph">
878 <p>You should see that the name printed matches the one you see when you run:
</p>
880 <div class=
"listingblock">
881 <div class=
"content">
882 <pre>$ git config --get user.name
</pre>
885 <div class=
"paragraph">
886 <p>Great! Now we know how to check for values in the Git config. Let
’s commit this
887 too, so we don
’t lose our progress.
</p>
889 <div class=
"listingblock">
890 <div class=
"content">
891 <pre>$ git add builtin/psuh.c
892 $ git commit -sm
"psuh: show parameters & config opts"</pre>
895 <div class=
"admonitionblock note">
899 <div class=
"title">Note
</div>
902 Again, the above is for sake of brevity in this tutorial. In a real change
903 you should not use
<code>-m
</code> but instead use the editor to write a meaningful
909 <div class=
"paragraph">
910 <p>Still, it
’d be nice to know what the user
’s working context is like. Let
’s see
911 if we can print the name of the user
’s current branch. We can mimic the
912 <code>git
</code> <code>status
</code> implementation; the printer is located in
<code>wt-status.c
</code> and we can
913 see that the branch is held in a
<code>struct
</code> <code>wt_status
</code>.
</p>
915 <div class=
"paragraph">
916 <p><code>wt_status_print
</code>() gets invoked by
<code>cmd_status
</code>() in
<code>builtin/commit.c
</code>.
917 Looking at that implementation we see the status config being populated like so:
</p>
919 <div class=
"listingblock">
920 <div class=
"content">
921 <pre>status_init_config(
&s, git_status_config);
</pre>
924 <div class=
"paragraph">
925 <p>But as we drill down, we can find that
<code>status_init_config
</code>() wraps a call
926 to
<code>git_config
</code>(). Let
’s modify the code we wrote in the previous commit.
</p>
928 <div class=
"paragraph">
929 <p>Be sure to include the header to allow you to use
<code>struct
</code> <code>wt_status
</code>:
</p>
931 <div class=
"listingblock">
932 <div class=
"content">
933 <pre>#include
"wt-status.h"</pre>
936 <div class=
"paragraph">
937 <p>Then modify your
<code>cmd_psuh
</code> implementation to declare your
<code>struct
</code> <code>wt_status
</code>,
938 prepare it, and print its contents:
</p>
940 <div class=
"listingblock">
941 <div class=
"content">
942 <pre> struct wt_status status;
946 wt_status_prepare(the_repository,
&status);
947 git_config(git_default_config,
&status);
951 printf(_(
"Your current branch: %s\n"), status.branch);
</pre>
954 <div class=
"paragraph">
955 <p>Run it again. Check it out - here
’s the (verbose) name of your current branch!
</p>
957 <div class=
"paragraph">
958 <p>Let
’s commit this as well.
</p>
960 <div class=
"listingblock">
961 <div class=
"content">
962 <pre>$ git add builtin/psuh.c
963 $ git commit -sm
"psuh: print the current branch"</pre>
966 <div class=
"paragraph">
967 <p>Now let
’s see if we can get some info about a specific commit.
</p>
969 <div class=
"paragraph">
970 <p>Luckily, there are some helpers for us here.
<code>commit.h
</code> has a function called
971 <code>lookup_commit_reference_by_name
</code> to which we can simply provide a hardcoded
972 string;
<code>pretty.h
</code> has an extremely handy
<code>pp_commit_easy
</code>() call which doesn
’t
973 require a full format object to be passed.
</p>
975 <div class=
"paragraph">
976 <p>Add the following includes:
</p>
978 <div class=
"listingblock">
979 <div class=
"content">
980 <pre>#include
"commit.h"
981 #include
"pretty.h"</pre>
984 <div class=
"paragraph">
985 <p>Then, add the following lines within your implementation of
<code>cmd_psuh
</code>() near
986 the declarations and the logic, respectively.
</p>
988 <div class=
"listingblock">
989 <div class=
"content">
990 <pre> struct commit *c = NULL;
991 struct strbuf commitline = STRBUF_INIT;
995 c = lookup_commit_reference_by_name(
"origin/master");
998 pp_commit_easy(CMIT_FMT_ONELINE, c,
&commitline);
999 printf(_(
"Current commit: %s\n"), commitline.buf);
1003 <div class=
"paragraph">
1004 <p>The
<code>struct
</code> <code>strbuf
</code> provides some safety belts to your basic
<code>char
</code>*, one of
1005 which is a length member to prevent buffer overruns. It needs to be initialized
1006 nicely with
<code>STRBUF_INIT
</code>. Keep it in mind when you need to pass around
<code>char
</code>*.
</p>
1008 <div class=
"paragraph">
1009 <p><code>lookup_commit_reference_by_name
</code> resolves the name you pass it, so you can play
1010 with the value there and see what kind of things you can come up with.
</p>
1012 <div class=
"paragraph">
1013 <p><code>pp_commit_easy
</code> is a convenience wrapper in
<code>pretty.h
</code> that takes a single
1014 format enum shorthand, rather than an entire format struct. It then
1015 pretty-prints the commit according to that shorthand. These are similar to the
1016 formats available with
<code>--pretty=FOO
</code> in many Git commands.
</p>
1018 <div class=
"paragraph">
1019 <p>Build it and run, and if you
’re using the same name in the example, you should
1020 see the subject line of the most recent commit in
<code>origin/master
</code> that you know
1021 about. Neat! Let
’s commit that as well.
</p>
1023 <div class=
"listingblock">
1024 <div class=
"content">
1025 <pre>$ git add builtin/psuh.c
1026 $ git commit -sm
"psuh: display the top of origin/master"</pre>
1031 <h3 id=
"add-documentation"><a class=
"anchor" href=
"#add-documentation"></a>Adding Documentation
</h3>
1032 <div class=
"paragraph">
1033 <p>Awesome! You
’ve got a fantastic new command that you
’re ready to share with the
1034 community. But hang on just a minute - this isn
’t very user-friendly. Run the
1037 <div class=
"listingblock">
1038 <div class=
"content">
1039 <pre>$ ./bin-wrappers/git help psuh
</pre>
1042 <div class=
"paragraph">
1043 <p>Your new command is undocumented! Let
’s fix that.
</p>
1045 <div class=
"paragraph">
1046 <p>Take a look at
<code>Documentation/git-
</code>*.
<code>txt
</code>. These are the manpages for the
1047 subcommands that Git knows about. You can open these up and take a look to get
1048 acquainted with the format, but then go ahead and make a new file
1049 <code>Documentation/git-psuh.txt
</code>. Like with most of the documentation in the Git
1050 project, help pages are written with AsciiDoc (see CodingGuidelines,
"Writing
1051 Documentation" section). Use the following template to fill out your own
1054 <div class=
"listingblock">
1055 <div class=
"content">
1061 git-psuh - Delight users' typo with a shy horse
1067 'git-psuh [
<arg
>...]'
1083 Part of the linkgit:git[
1] suite
</pre>
1086 <div class=
"paragraph">
1087 <p>The most important pieces of this to note are the file header, underlined by =,
1088 the NAME section, and the SYNOPSIS, which would normally contain the grammar if
1089 your command took arguments. Try to use well-established manpage headers so your
1090 documentation is consistent with other Git and UNIX manpages; this makes life
1091 easier for your user, who can skip to the section they know contains the
1092 information they need.
</p>
1094 <div class=
"admonitionblock note">
1098 <div class=
"title">Note
</div>
1100 <td class=
"content">
1101 Before trying to build the docs, make sure you have the package
<code>asciidoc
</code>
1107 <div class=
"paragraph">
1108 <p>Now that you
’ve written your manpage, you
’ll need to build it explicitly. We
1109 convert your AsciiDoc to troff which is man-readable like so:
</p>
1111 <div class=
"listingblock">
1112 <div class=
"content">
1114 $ man Documentation/git-psuh
.1</pre>
1117 <div class=
"paragraph">
1120 <div class=
"listingblock">
1121 <div class=
"content">
1122 <pre>$ make -C Documentation/ git-psuh
.1
1123 $ man Documentation/git-psuh
.1</pre>
1126 <div class=
"paragraph">
1127 <p>While this isn
’t as satisfying as running through
<code>git
</code> <code>help
</code>, you can at least
1128 check that your help page looks right.
</p>
1130 <div class=
"paragraph">
1131 <p>You can also check that the documentation coverage is good (that is, the project
1132 sees that your command has been implemented as well as documented) by running
1133 <code>make
</code> <code>check-docs
</code> from the top-level.
</p>
1135 <div class=
"paragraph">
1136 <p>Go ahead and commit your new documentation change.
</p>
1140 <h3 id=
"add-usage"><a class=
"anchor" href=
"#add-usage"></a>Adding Usage Text
</h3>
1141 <div class=
"paragraph">
1142 <p>Try and run .
<code>/bin-wrappers/git
</code> <code>psuh
</code> <code>-h
</code>. Your command should crash at the end.
1143 That
’s because
<code>-h
</code> is a special case which your command should handle by
1146 <div class=
"paragraph">
1147 <p>Take a look at
<code>Documentation/technical/api-parse-options.txt
</code>. This is a handy
1148 tool for pulling out options you need to be able to handle, and it takes a
1151 <div class=
"paragraph">
1152 <p>In order to use it, we
’ll need to prepare a NULL-terminated array of usage
1153 strings and a
<code>builtin_psuh_options
</code> array.
</p>
1155 <div class=
"paragraph">
1156 <p>Add a line to #include
"parse-options.<code>h</code>".
</p>
1158 <div class=
"paragraph">
1159 <p>At global scope, add your array of usage strings:
</p>
1161 <div class=
"listingblock">
1162 <div class=
"content">
1163 <pre>static const char * const psuh_usage[] = {
1164 N_(
"git psuh [<arg>...]"),
1169 <div class=
"paragraph">
1170 <p>Then, within your
<code>cmd_psuh
</code>() implementation, we can declare and populate our
1171 <code>option
</code> struct. Ours is pretty boring but you can add more to it if you want to
1172 explore
<code>parse_options
</code>() in more detail:
</p>
1174 <div class=
"listingblock">
1175 <div class=
"content">
1176 <pre> struct option options[] = {
1181 <div class=
"paragraph">
1182 <p>Finally, before you print your args and prefix, add the call to
1183 <code>parse-options
</code>():
</p>
1185 <div class=
"listingblock">
1186 <div class=
"content">
1187 <pre> argc = parse_options(argc, argv, prefix, options, psuh_usage,
0);
</pre>
1190 <div class=
"paragraph">
1191 <p>This call will modify your
<code>argv
</code> parameter. It will strip the options you
1192 specified in
<code>options
</code> from
<code>argv
</code> and the locations pointed to from
<code>options
</code>
1193 entries will be updated. Be sure to replace your
<code>argc
</code> with the result from
1194 <code>parse_options
</code>(), or you will be confused if you try to parse
<code>argv
</code> later.
</p>
1196 <div class=
"paragraph">
1197 <p>It
’s worth noting the special argument
<code>--
</code>. As you may be aware, many Unix
1198 commands use
<code>--
</code> to indicate
"end of named parameters" - all parameters after
1199 the
<code>--
</code> are interpreted merely as positional arguments. (This can be handy if
1200 you want to pass as a parameter something which would usually be interpreted as
1201 a flag.)
<code>parse_options
</code>() will terminate parsing when it reaches
<code>--
</code> and give
1202 you the rest of the options afterwards, untouched.
</p>
1204 <div class=
"paragraph">
1205 <p>Now that you have a usage hint, you can teach Git how to show it in the general
1206 command list shown by
<code>git
</code> <code>help
</code> <code>git
</code> or
<code>git
</code> <code>help
</code> <code>-a
</code>, which is generated from
1207 <code>command-list.txt
</code>. Find the line for
<em>git-pull
</em> so you can add your
<em>git-psuh
</em>
1208 line above it in alphabetical order. Now, we can add some attributes about the
1209 command which impacts where it shows up in the aforementioned help commands. The
1210 top of
<code>command-list.txt
</code> shares some information about what each attribute
1211 means; in those help pages, the commands are sorted according to these
1212 attributes.
<code>git
</code> <code>psuh
</code> is user-facing, or porcelain - so we will mark it as
1213 "mainporcelain". For
"mainporcelain" commands, the comments at the top of
1214 <code>command-list.txt
</code> indicate we can also optionally add an attribute from another
1215 list; since
<code>git
</code> <code>psuh
</code> shows some information about the user
’s workspace but
1216 doesn
’t modify anything, let
’s mark it as
"info". Make sure to keep your
1217 attributes in the same style as the rest of
<code>command-list.txt
</code> using spaces to
1218 align and delineate them:
</p>
1220 <div class=
"listingblock">
1221 <div class=
"content">
1222 <pre>git-prune-packed plumbingmanipulators
1223 git-psuh mainporcelain info
1224 git-pull mainporcelain remote
1225 git-push mainporcelain remote
</pre>
1228 <div class=
"paragraph">
1229 <p>Build again. Now, when you run with
<code>-h
</code>, you should see your usage printed and
1230 your command terminated before anything else interesting happens. Great!
</p>
1232 <div class=
"paragraph">
1233 <p>Go ahead and commit this one, too.
</p>
1239 <h2 id=
"testing"><a class=
"anchor" href=
"#testing"></a>Testing
</h2>
1240 <div class=
"sectionbody">
1241 <div class=
"paragraph">
1242 <p>It
’s important to test your code - even for a little toy command like this one.
1243 Moreover, your patch won
’t be accepted into the Git tree without tests. Your
1249 <p>Illustrate the current behavior of the feature
</p>
1252 <p>Prove the current behavior matches the expected behavior
</p>
1255 <p>Ensure the externally-visible behavior isn
’t broken in later changes
</p>
1259 <div class=
"paragraph">
1260 <p>So let
’s write some tests.
</p>
1262 <div class=
"paragraph">
1263 <p>Related reading:
<code>t/README
</code></p>
1266 <h3 id=
"overview-test-structure"><a class=
"anchor" href=
"#overview-test-structure"></a>Overview of Testing Structure
</h3>
1267 <div class=
"paragraph">
1268 <p>The tests in Git live in
<code>t/
</code> and are named with a
4-digit decimal number using
1269 the schema shown in the Naming Tests section of
<code>t/README
</code>.
</p>
1273 <h3 id=
"write-new-test"><a class=
"anchor" href=
"#write-new-test"></a>Writing Your Test
</h3>
1274 <div class=
"paragraph">
1275 <p>Since this a toy command, let
’s go ahead and name the test with t9999. However,
1276 as many of the family/subcmd combinations are full, best practice seems to be
1277 to find a command close enough to the one you
’ve added and share its naming
1280 <div class=
"paragraph">
1281 <p>Create a new file
<code>t/t9999-psuh-tutorial.sh
</code>. Begin with the header as so (see
1282 "Writing Tests" and
"Source <em>test-lib.sh</em>" in
<code>t/README
</code>):
</p>
1284 <div class=
"listingblock">
1285 <div class=
"content">
1288 test_description='git-psuh test
1290 This test runs git-psuh and makes sure it does not crash.'
1292 . ./test-lib.sh
</pre>
1295 <div class=
"paragraph">
1296 <p>Tests are framed inside of a
<code>test_expect_success
</code> in order to output TAP
1297 formatted results. Let
’s make sure that
<code>git
</code> <code>psuh
</code> doesn
’t exit poorly and does
1298 mention the right animal somewhere:
</p>
1300 <div class=
"listingblock">
1301 <div class=
"content">
1302 <pre>test_expect_success 'runs correctly with no args and good output' '
1303 git psuh
>actual
&&
1308 <div class=
"paragraph">
1309 <p>Indicate that you
’ve run everything you wanted by adding the following at the
1310 bottom of your script:
</p>
1312 <div class=
"listingblock">
1313 <div class=
"content">
1314 <pre>test_done
</pre>
1317 <div class=
"paragraph">
1318 <p>Make sure you mark your test script executable:
</p>
1320 <div class=
"listingblock">
1321 <div class=
"content">
1322 <pre>$ chmod +x t/t9999-psuh-tutorial.sh
</pre>
1325 <div class=
"paragraph">
1326 <p>You can get an idea of whether you created your new test script successfully
1327 by running
<code>make
</code> <code>-C
</code> <code>t
</code> <code>test-lint
</code>, which will check for things like test number
1328 uniqueness, executable bit, and so on.
</p>
1332 <h3 id=
"local-test"><a class=
"anchor" href=
"#local-test"></a>Running Locally
</h3>
1333 <div class=
"paragraph">
1334 <p>Let
’s try and run locally:
</p>
1336 <div class=
"listingblock">
1337 <div class=
"content">
1339 $ cd t/
&& prove t9999-psuh-tutorial.sh
</pre>
1342 <div class=
"paragraph">
1343 <p>You can run the full test suite and ensure
<code>git-psuh
</code> didn
’t break anything:
</p>
1345 <div class=
"listingblock">
1346 <div class=
"content">
1348 $ prove -j$(nproc) --shuffle t[
0-
9]*.sh
</pre>
1351 <div class=
"admonitionblock note">
1355 <div class=
"title">Note
</div>
1357 <td class=
"content">
1358 You can also do this with
<code>make
</code> <code>test
</code> or use any testing harness which can
1359 speak TAP.
<code>prove
</code> can run concurrently.
<code>shuffle
</code> randomizes the order the
1360 tests are run in, which makes them resilient against unwanted inter-test
1361 dependencies.
<code>prove
</code> also makes the output nicer.
1366 <div class=
"paragraph">
1367 <p>Go ahead and commit this change, as well.
</p>
1373 <h2 id=
"ready-to-share"><a class=
"anchor" href=
"#ready-to-share"></a>Getting Ready to Share: Anatomy of a Patch Series
</h2>
1374 <div class=
"sectionbody">
1375 <div class=
"paragraph">
1376 <p>You may have noticed already that the Git project performs its code reviews via
1377 emailed patches, which are then applied by the maintainer when they are ready
1378 and approved by the community. The Git project does not accept contributions from
1379 pull requests, and the patches emailed for review need to be formatted a
1382 <div class=
"paragraph">
1383 <p>Before taking a look at how to convert your commits into emailed patches,
1384 let
’s analyze what the end result, a
"patch series", looks like. Here is an
1385 <a href=
"https://lore.kernel.org/git/pull.1218.git.git.1645209647.gitgitgadget@gmail.com/">example
</a> of the summary view for a patch series on the web interface of
1386 the
<a href=
"https://lore.kernel.org/git/">Git mailing list archive
</a>:
</p>
1388 <div class=
"listingblock">
1389 <div class=
"content">
1390 <pre>2022-
02-
18 18:
40 [PATCH
0/
3] libify reflog John Cai via GitGitGadget
1391 2022-
02-
18 18:
40 ` [PATCH
1/
3] reflog: libify delete reflog function and helpers John Cai via GitGitGadget
1392 2022-
02-
18 19:
10 ` Ævar Arnfjörð Bjarmason [this message]
1393 2022-
02-
18 19:
39 ` Taylor Blau
1394 2022-
02-
18 19:
48 ` Ævar Arnfjörð Bjarmason
1395 2022-
02-
18 19:
35 ` Taylor Blau
1396 2022-
02-
21 1:
43 ` John Cai
1397 2022-
02-
21 1:
50 ` Taylor Blau
1398 2022-
02-
23 19:
50 ` John Cai
1399 2022-
02-
18 20:
00 ` // other replies elided
1400 2022-
02-
18 18:
40 ` [PATCH
2/
3] reflog: call reflog_delete from reflog.c John Cai via GitGitGadget
1401 2022-
02-
18 19:
15 ` Ævar Arnfjörð Bjarmason
1402 2022-
02-
18 20:
26 ` Junio C Hamano
1403 2022-
02-
18 18:
40 ` [PATCH
3/
3] stash: call reflog_delete from reflog.c John Cai via GitGitGadget
1404 2022-
02-
18 19:
20 ` Ævar Arnfjörð Bjarmason
1405 2022-
02-
19 0:
21 ` Taylor Blau
1406 2022-
02-
22 2:
36 ` John Cai
1407 2022-
02-
22 10:
51 ` Ævar Arnfjörð Bjarmason
1408 2022-
02-
18 19:
29 ` [PATCH
0/
3] libify reflog Ævar Arnfjörð Bjarmason
1409 2022-
02-
22 18:
30 ` [PATCH v2
0/
3] libify reflog John Cai via GitGitGadget
1410 2022-
02-
22 18:
30 ` [PATCH v2
1/
3] stash: add test to ensure reflog --rewrite --updatref behavior John Cai via GitGitGadget
1411 2022-
02-
23 8:
54 ` Ævar Arnfjörð Bjarmason
1412 2022-
02-
23 21:
27 ` Junio C Hamano
1416 <div class=
"paragraph">
1417 <p>We can note a few things:
</p>
1422 <p>Each commit is sent as a separate email, with the commit message title as
1423 subject, prefixed with
"[PATCH <em>i</em>/<em>n</em>]" for the
<em>i
</em>-th commit of an
1424 <em>n
</em>-commit series.
</p>
1427 <p>Each patch is sent as a reply to an introductory email called the
<em>cover
1428 letter
</em> of the series, prefixed
"[PATCH 0/<em>n</em>]".
</p>
1431 <p>Subsequent iterations of the patch series are labelled
"PATCH v2",
"PATCH
1432 v3", etc. in place of
"PATCH". For example,
"[PATCH v2 1/3]" would be the first of
1433 three patches in the second iteration. Each iteration is sent with a new cover
1434 letter (like
"[PATCH v2 0/3]" above), itself a reply to the cover letter of the
1435 previous iteration (more on that below).
</p>
1439 <div class=
"admonitionblock note">
1443 <div class=
"title">Note
</div>
1445 <td class=
"content">
1446 A single-patch topic is sent with
"[PATCH]",
"[PATCH v2]", etc. without
1447 <em>i
</em>/
<em>n
</em> numbering (in the above thread overview, no single-patch topic appears,
1454 <h3 id=
"cover-letter"><a class=
"anchor" href=
"#cover-letter"></a>The cover letter
</h3>
1455 <div class=
"paragraph">
1456 <p>In addition to an email per patch, the Git community also expects your patches
1457 to come with a cover letter. This is an important component of change
1458 submission as it explains to the community from a high level what you
’re trying
1459 to do, and why, in a way that
’s more apparent than just looking at your
1462 <div class=
"paragraph">
1463 <p>The title of your cover letter should be something which succinctly covers the
1464 purpose of your entire topic branch. It
’s often in the imperative mood, just
1465 like our commit message titles. Here is how we
’ll title our series:
</p>
1468 <div class=
"paragraph">
1469 <p>Add the
<em>psuh
</em> command
1472 <div class=
"paragraph">
1473 <p>The body of the cover letter is used to give additional context to reviewers.
1474 Be sure to explain anything your patches don
’t make clear on their own, but
1475 remember that since the cover letter is not recorded in the commit history,
1476 anything that might be useful to future readers of the repository
’s history
1477 should also be in your commit messages.
</p>
1479 <div class=
"paragraph">
1480 <p>Here
’s an example body for
<code>psuh
</code>:
</p>
1482 <div class=
"listingblock">
1483 <div class=
"content">
1484 <pre>Our internal metrics indicate widespread interest in the command
1485 git-psuh - that is, many users are trying to use it, but finding it is
1486 unavailable, using some unknown workaround instead.
1488 The following handful of patches add the psuh command and implement some
1489 handy features on top of it.
1491 This patchset is part of the MyFirstContribution tutorial and should not
1495 <div class=
"paragraph">
1496 <p>At this point the tutorial diverges, in order to demonstrate two
1497 different methods of formatting your patchset and getting it reviewed.
</p>
1499 <div class=
"paragraph">
1500 <p>The first method to be covered is GitGitGadget, which is useful for those
1501 already familiar with GitHub
’s common pull request workflow. This method
1502 requires a GitHub account.
</p>
1504 <div class=
"paragraph">
1505 <p>The second method to be covered is
<code>git
</code> <code>send-email
</code>, which can give slightly
1506 more fine-grained control over the emails to be sent. This method requires some
1507 setup which can change depending on your system and will not be covered in this
1510 <div class=
"paragraph">
1511 <p>Regardless of which method you choose, your engagement with reviewers will be
1512 the same; the review process will be covered after the sections on GitGitGadget
1513 and
<code>git
</code> <code>send-email
</code>.
</p>
1519 <h2 id=
"howto-ggg"><a class=
"anchor" href=
"#howto-ggg"></a>Sending Patches via GitGitGadget
</h2>
1520 <div class=
"sectionbody">
1521 <div class=
"paragraph">
1522 <p>One option for sending patches is to follow a typical pull request workflow and
1523 send your patches out via GitGitGadget. GitGitGadget is a tool created by
1524 Johannes Schindelin to make life as a Git contributor easier for those used to
1525 the GitHub PR workflow. It allows contributors to open pull requests against its
1526 mirror of the Git project, and does some magic to turn the PR into a set of
1527 emails and send them out for you. It also runs the Git continuous integration
1528 suite for you. It
’s documented at
<a href=
"https://gitgitgadget.github.io/" class=
"bare">https://gitgitgadget.github.io/
</a>.
</p>
1531 <h3 id=
"create-fork"><a class=
"anchor" href=
"#create-fork"></a>Forking
<code>git/git
</code> on GitHub
</h3>
1532 <div class=
"paragraph">
1533 <p>Before you can send your patch off to be reviewed using GitGitGadget, you will
1534 need to fork the Git project and upload your changes. First thing - make sure
1535 you have a GitHub account.
</p>
1537 <div class=
"paragraph">
1538 <p>Head to the
<a href=
"https://github.com/git/git">GitHub mirror
</a> and look for the Fork
1539 button. Place your fork wherever you deem appropriate and create it.
</p>
1543 <h3 id=
"upload-to-fork"><a class=
"anchor" href=
"#upload-to-fork"></a>Uploading to Your Own Fork
</h3>
1544 <div class=
"paragraph">
1545 <p>To upload your branch to your own fork, you
’ll need to add the new fork as a
1546 remote. You can use
<code>git
</code> <code>remote
</code> <code>-v
</code> to show the remotes you have added already.
1547 From your new fork
’s page on GitHub, you can press
"Clone or download" to get
1548 the URL; then you need to run the following to add, replacing your own URL and
1549 remote name for the examples provided:
</p>
1551 <div class=
"listingblock">
1552 <div class=
"content">
1553 <pre>$ git remote add remotename git@github.com:remotename/git.git
</pre>
1556 <div class=
"paragraph">
1557 <p>or to use the HTTPS URL:
</p>
1559 <div class=
"listingblock">
1560 <div class=
"content">
1561 <pre>$ git remote add remotename https://github.com/remotename/git/.git
</pre>
1564 <div class=
"paragraph">
1565 <p>Run
<code>git
</code> <code>remote
</code> <code>-v
</code> again and you should see the new remote showing up.
1566 <code>git
</code> <code>fetch
</code> <code>remotename
</code> (with the real name of your remote replaced) in order to
1567 get ready to push.
</p>
1569 <div class=
"paragraph">
1570 <p>Next, double-check that you
’ve been doing all your development in a new branch
1571 by running
<code>git
</code> <code>branch
</code>. If you didn
’t, now is a good time to move your new
1572 commits to their own branch.
</p>
1574 <div class=
"paragraph">
1575 <p>As mentioned briefly at the beginning of this document, we are basing our work
1576 on
<code>master
</code>, so go ahead and update as shown below, or using your preferred
1579 <div class=
"listingblock">
1580 <div class=
"content">
1581 <pre>$ git checkout master
1583 $ git rebase master psuh
</pre>
1586 <div class=
"paragraph">
1587 <p>Finally, you
’re ready to push your new topic branch! (Due to our branch and
1588 command name choices, be careful when you type the command below.)
</p>
1590 <div class=
"listingblock">
1591 <div class=
"content">
1592 <pre>$ git push remotename psuh
</pre>
1595 <div class=
"paragraph">
1596 <p>Now you should be able to go and check out your newly created branch on GitHub.
</p>
1600 <h3 id=
"send-pr-ggg"><a class=
"anchor" href=
"#send-pr-ggg"></a>Sending a PR to GitGitGadget
</h3>
1601 <div class=
"paragraph">
1602 <p>In order to have your code tested and formatted for review, you need to start by
1603 opening a Pull Request against
<code>gitgitgadget/git
</code>. Head to
1604 <a href=
"https://github.com/gitgitgadget/git" class=
"bare">https://github.com/gitgitgadget/git
</a> and open a PR either with the
"New pull
1605 request" button or the convenient
"Compare & pull request" button that may
1606 appear with the name of your newly pushed branch.
</p>
1608 <div class=
"paragraph">
1609 <p>Review the PR
’s title and description, as they
’re used by GitGitGadget
1610 respectively as the subject and body of the cover letter for your change. Refer
1611 to
<a href=
"#cover-letter">"The cover letter"</a> above for advice on how to title your
1612 submission and what content to include in the description.
</p>
1614 <div class=
"admonitionblock note">
1618 <div class=
"title">Note
</div>
1620 <td class=
"content">
1621 For single-patch contributions, your commit message should already be
1622 meaningful and explain at a high level the purpose (what is happening and why)
1623 of your patch, so you usually do not need any additional context. In that case,
1624 remove the PR description that GitHub automatically generates from your commit
1625 message (your PR description should be empty). If you do need to supply even
1626 more context, you can do so in that space and it will be appended to the email
1627 that GitGitGadget will send, between the three-dash line and the diffstat
1628 (see
<a href=
"#single-patch">Bonus Chapter: One-Patch Changes
</a> for how this looks once
1634 <div class=
"paragraph">
1635 <p>When you
’re happy, submit your pull request.
</p>
1639 <h3 id=
"run-ci-ggg"><a class=
"anchor" href=
"#run-ci-ggg"></a>Running CI and Getting Ready to Send
</h3>
1640 <div class=
"paragraph">
1641 <p>If it
’s your first time using GitGitGadget (which is likely, as you
’re using
1642 this tutorial) then someone will need to give you permission to use the tool.
1643 As mentioned in the GitGitGadget documentation, you just need someone who
1644 already uses it to comment on your PR with
<code>/allow
</code> <em><username
></em>. GitGitGadget
1645 will automatically run your PRs through the CI even without the permission given
1646 but you will not be able to
<code>/submit
</code> your changes until someone allows you to
1649 <div class=
"admonitionblock note">
1653 <div class=
"title">Note
</div>
1655 <td class=
"content">
1656 You can typically find someone who can
<code>/allow
</code> you on GitGitGadget by
1657 either examining recent pull requests where someone has been granted
<code>/allow
</code>
1658 (
<a href=
"https://github.com/gitgitgadget/git/pulls?utf8=%E2%9C%93&q=is%3Apr+is%3Aopen+%22%2Fallow%22">Search:
1659 is:pr is:open
"/allow"</a>), in which case both the author and the person who
1660 granted the
<code>/allow
</code> can now
<code>/allow
</code> you, or by inquiring on the
1661 <a href=
"https://web.libera.chat/#git-devel">#git-devel
</a> IRC channel on Libera Chat
1662 linking your pull request and asking for someone to
<code>/allow
</code> you.
1667 <div class=
"paragraph">
1668 <p>If the CI fails, you can update your changes with
<code>git
</code> <code>rebase
</code> <code>-i
</code> and push your
1671 <div class=
"listingblock">
1672 <div class=
"content">
1673 <pre>$ git push -f remotename psuh
</pre>
1676 <div class=
"paragraph">
1677 <p>In fact, you should continue to make changes this way up until the point when
1678 your patch is accepted into
<code>next
</code>.
</p>
1682 <h3 id=
"send-mail-ggg"><a class=
"anchor" href=
"#send-mail-ggg"></a>Sending Your Patches
</h3>
1683 <div class=
"paragraph">
1684 <p>Now that your CI is passing and someone has granted you permission to use
1685 GitGitGadget with the
<code>/allow
</code> command, sending out for review is as simple as
1686 commenting on your PR with
<code>/submit
</code>.
</p>
1690 <h3 id=
"responding-ggg"><a class=
"anchor" href=
"#responding-ggg"></a>Updating With Comments
</h3>
1691 <div class=
"paragraph">
1692 <p>Skip ahead to
<a href=
"#reviewing">Responding to Reviews
</a> for information on how to
1693 reply to review comments you will receive on the mailing list.
</p>
1695 <div class=
"paragraph">
1696 <p>Once you have your branch again in the shape you want following all review
1697 comments, you can submit again:
</p>
1699 <div class=
"listingblock">
1700 <div class=
"content">
1701 <pre>$ git push -f remotename psuh
</pre>
1704 <div class=
"paragraph">
1705 <p>Next, go look at your pull request against GitGitGadget; you should see the CI
1706 has been kicked off again. Now while the CI is running is a good time for you
1707 to modify your description at the top of the pull request thread; it will be
1708 used again as the cover letter. You should use this space to describe what
1709 has changed since your previous version, so that your reviewers have some idea
1710 of what they
’re looking at. When the CI is done running, you can comment once
1711 more with
<code>/submit
</code> - GitGitGadget will automatically add a v2 mark to your
1718 <h2 id=
"howto-git-send-email"><a class=
"anchor" href=
"#howto-git-send-email"></a>Sending Patches with
<code>git
</code> <code>send-email
</code></h2>
1719 <div class=
"sectionbody">
1720 <div class=
"paragraph">
1721 <p>If you don
’t want to use GitGitGadget, you can also use Git itself to mail your
1722 patches. Some benefits of using Git this way include finer grained control of
1723 subject line (for example, being able to use the tag [RFC PATCH] in the subject)
1724 and being able to send a
“dry run
” mail to yourself to ensure it all looks
1725 good before going out to the list.
</p>
1728 <h3 id=
"setup-git-send-email"><a class=
"anchor" href=
"#setup-git-send-email"></a>Prerequisite: Setting Up
<code>git
</code> <code>send-email
</code></h3>
1729 <div class=
"paragraph">
1730 <p>Configuration for
<code>send-email
</code> can vary based on your operating system and email
1731 provider, and so will not be covered in this tutorial, beyond stating that in
1732 many distributions of Linux,
<code>git-send-email
</code> is not packaged alongside the
1733 typical
<code>git
</code> install. You may need to install this additional package; there
1734 are a number of resources online to help you do so. You will also need to
1735 determine the right way to configure it to use your SMTP server; again, as this
1736 configuration can change significantly based on your system and email setup, it
1737 is out of scope for the context of this tutorial.
</p>
1741 <h3 id=
"format-patch"><a class=
"anchor" href=
"#format-patch"></a>Preparing Initial Patchset
</h3>
1742 <div class=
"paragraph">
1743 <p>Sending emails with Git is a two-part process; before you can prepare the emails
1744 themselves, you
’ll need to prepare the patches. Luckily, this is pretty simple:
</p>
1746 <div class=
"listingblock">
1747 <div class=
"content">
1748 <pre>$ git format-patch --cover-letter -o psuh/ --base=auto psuh@{u}..psuh
</pre>
1751 <div class=
"olist arabic">
1754 <p>The
<code>--cover-letter
</code> option tells
<code>format-patch
</code> to create a
1755 cover letter template for you. You will need to fill in the
1756 template before you
’re ready to send - but for now, the template
1757 will be next to your other patches.
</p>
1760 <p>The
<code>-o
</code> <code>psuh/
</code> option tells
<code>format-patch
</code> to place the patch
1761 files into a directory. This is useful because
<code>git
</code> <code>send-email
</code>
1762 can take a directory and send out all the patches from there.
</p>
1765 <p>The
<code>--base=auto
</code> option tells the command to record the
"base
1766 commit", on which the recipient is expected to apply the patch
1767 series. The
<code>auto
</code> value will cause
<code>format-patch
</code> to compute
1768 the base commit automatically, which is the merge base of tip
1769 commit of the remote-tracking branch and the specified revision
1773 <p>The
<code>psuh@
</code>{u}
<code>..
</code><code>psuh
</code> option tells
<code>format-patch
</code> to generate
1774 patches for the commits you created on the
<code>psuh
</code> branch since it
1775 forked from its upstream (which is
<code>origin/master
</code> if you
1776 followed the example in the
"Set up your workspace" section). If
1777 you are already on the
<code>psuh
</code> branch, you can just say
<code>@
</code>{u},
1778 which means
"commits on the current branch since it forked from
1779 its upstream", which is the same thing.
</p>
1783 <div class=
"paragraph">
1784 <p>The command will make one patch file per commit. After you
1785 run, you can go have a look at each of the patches with your favorite text
1786 editor and make sure everything looks alright; however, it
’s not recommended to
1787 make code fixups via the patch file. It
’s a better idea to make the change the
1788 normal way using
<code>git
</code> <code>rebase
</code> <code>-i
</code> or by adding a new commit than by modifying a
1791 <div class=
"admonitionblock note">
1795 <div class=
"title">Note
</div>
1797 <td class=
"content">
1798 Optionally, you can also use the
<code>--rfc
</code> flag to prefix your patch subject
1799 with
“[RFC PATCH]
” instead of
“[PATCH]
”. RFC stands for
“request for
1800 comments
” and indicates that while your code isn
’t quite ready for submission,
1801 you
’d like to begin the code review process. This can also be used when your
1802 patch is a proposal, but you aren
’t sure whether the community wants to solve
1803 the problem with that approach or not - to conduct a sort of design review. You
1804 may also see on the list patches marked
“WIP
” - this means they are incomplete
1805 but want reviewers to look at what they have so far. You can add this flag with
1806 <code>--subject-prefix=WIP
</code>.
1811 <div class=
"paragraph">
1812 <p>Check and make sure that your patches and cover letter template exist in the
1813 directory you specified - you
’re nearly ready to send out your review!
</p>
1817 <h3 id=
"preparing-cover-letter"><a class=
"anchor" href=
"#preparing-cover-letter"></a>Preparing Email
</h3>
1818 <div class=
"paragraph">
1819 <p>Since you invoked
<code>format-patch
</code> with
<code>--cover-letter
</code>, you
’ve already got a
1820 cover letter template ready. Open it up in your favorite editor.
</p>
1822 <div class=
"paragraph">
1823 <p>You should see a number of headers present already. Check that your
<code>From:
</code>
1824 header is correct. Then modify your
<code>Subject:
</code> (see
<a href=
"#cover-letter">above
</a> for
1825 how to choose good title for your patch series):
</p>
1827 <div class=
"listingblock">
1828 <div class=
"content">
1829 <pre>Subject: [PATCH
0/
7] Add the 'psuh' command
</pre>
1832 <div class=
"paragraph">
1833 <p>Make sure you retain the
“[PATCH
0/X]
” part; that
’s what indicates to the Git
1834 community that this email is the beginning of a patch series, and many
1835 reviewers filter their email for this type of flag.
</p>
1837 <div class=
"paragraph">
1838 <p>You
’ll need to add some extra parameters when you invoke
<code>git
</code> <code>send-email
</code> to add
1839 the cover letter.
</p>
1841 <div class=
"paragraph">
1842 <p>Next you
’ll have to fill out the body of your cover letter. Again, see
1843 <a href=
"#cover-letter">above
</a> for what content to include.
</p>
1845 <div class=
"paragraph">
1846 <p>The template created by
<code>git
</code> <code>format-patch
</code> <code>--cover-letter
</code> includes a diffstat.
1847 This gives reviewers a summary of what they
’re in for when reviewing your topic.
1848 The one generated for
<code>psuh
</code> from the sample implementation looks like this:
</p>
1850 <div class=
"listingblock">
1851 <div class=
"content">
1852 <pre> Documentation/git-psuh.txt |
40 +++++++++++++++++++++
1855 builtin/psuh.c |
73 ++++++++++++++++++++++++++++++++++++++
1857 t/t9999-psuh-tutorial.sh |
12 +++++++
1858 6 files changed,
128 insertions(+)
1859 create mode
100644 Documentation/git-psuh.txt
1860 create mode
100644 builtin/psuh.c
1861 create mode
100755 t/t9999-psuh-tutorial.sh
</pre>
1864 <div class=
"paragraph">
1865 <p>Finally, the letter will include the version of Git used to generate the
1866 patches. You can leave that string alone.
</p>
1870 <h3 id=
"sending-git-send-email"><a class=
"anchor" href=
"#sending-git-send-email"></a>Sending Email
</h3>
1871 <div class=
"paragraph">
1872 <p>At this point you should have a directory
<code>psuh/
</code> which is filled with your
1873 patches and a cover letter. Time to mail it out! You can send it like this:
</p>
1875 <div class=
"listingblock">
1876 <div class=
"content">
1877 <pre>$ git send-email --to=target@example.com psuh/*.patch
</pre>
1880 <div class=
"admonitionblock note">
1884 <div class=
"title">Note
</div>
1886 <td class=
"content">
1887 Check
<code>git
</code> <code>help
</code> <code>send-email
</code> for some other options which you may find
1888 valuable, such as changing the Reply-to address or adding more CC and BCC lines.
1893 <div class=
"admonitionblock note">
1897 <div class=
"title">Note
</div>
1899 <td class=
"content">
1900 If you
’re not sure whom to CC, running
<code>contrib/contacts/git-contacts
</code> can
1901 list potential reviewers. In addition, you can do
<code>git
</code> <code>send-email
</code>
1902 <code>--cc-cmd=
</code>'perl
<code>contrib/contacts/git-contacts
</code>'
<code>feature/
</code>*.
<code>patch
</code><sup class=
"footnote" id=
"_footnote_contrib-scripts">[
<a id=
"_footnoteref_1" class=
"footnote" href=
"#_footnotedef_1" title=
"View footnote.">1</a>]
</sup> to
1903 automatically pass this list of emails to
<code>send-email
</code>.
1908 <div class=
"admonitionblock note">
1912 <div class=
"title">Note
</div>
1914 <td class=
"content">
1915 When you are sending a real patch, it will go to
<a href=
"mailto:git@vger.kernel.org">git@vger.kernel.org
</a> - but
1916 please don
’t send your patchset from the tutorial to the real mailing list! For
1917 now, you can send it to yourself, to make sure you understand how it will look.
1922 <div class=
"paragraph">
1923 <p>After you run the command above, you will be presented with an interactive
1924 prompt for each patch that
’s about to go out. This gives you one last chance to
1925 edit or quit sending something (but again, don
’t edit code this way). Once you
1926 press
<code>y
</code> or
<code>a
</code> at these prompts your emails will be sent! Congratulations!
</p>
1928 <div class=
"paragraph">
1929 <p>Awesome, now the community will drop everything and review your changes. (Just
1930 kidding - be patient!)
</p>
1934 <h3 id=
"v2-git-send-email"><a class=
"anchor" href=
"#v2-git-send-email"></a>Sending v2
</h3>
1935 <div class=
"paragraph">
1936 <p>This section will focus on how to send a v2 of your patchset. To learn what
1937 should go into v2, skip ahead to
<a href=
"#reviewing">Responding to Reviews
</a> for
1938 information on how to handle comments from reviewers.
</p>
1940 <div class=
"paragraph">
1941 <p>We
’ll reuse our
<code>psuh
</code> topic branch for v2. Before we make any changes, we
’ll
1942 mark the tip of our v1 branch for easy reference:
</p>
1944 <div class=
"listingblock">
1945 <div class=
"content">
1946 <pre>$ git checkout psuh
1947 $ git branch psuh-v1
</pre>
1950 <div class=
"paragraph">
1951 <p>Refine your patch series by using
<code>git
</code> <code>rebase
</code> <code>-i
</code> to adjust commits based upon
1952 reviewer comments. Once the patch series is ready for submission, generate your
1953 patches again, but with some new flags:
</p>
1955 <div class=
"listingblock">
1956 <div class=
"content">
1957 <pre>$ git format-patch -v2 --cover-letter -o psuh/ --range-diff master..psuh-v1 master..
</pre>
1960 <div class=
"paragraph">
1961 <p>The
<code>--range-diff
</code> <code>master
</code><code>..
</code><code>psuh-v1
</code> parameter tells
<code>format-patch
</code> to include a
1962 range-diff between
<code>psuh-v1
</code> and
<code>psuh
</code> in the cover letter (see
1963 <a href=
"git-range-diff.html">git-range-diff(
1)
</a>). This helps tell reviewers about the differences
1964 between your v1 and v2 patches.
</p>
1966 <div class=
"paragraph">
1967 <p>The
<code>-v2
</code> parameter tells
<code>format-patch
</code> to output your patches
1968 as version
"2". For instance, you may notice that your v2 patches are
1969 all named like
<code>v2-
000n-my-commit-subject.patch
</code>.
<code>-v2
</code> will also format
1970 your patches by prefixing them with
"[PATCH v2]" instead of
"[PATCH]",
1971 and your range-diff will be prefaced with
"Range-diff against v1".
</p>
1973 <div class=
"paragraph">
1974 <p>After you run this command,
<code>format-patch
</code> will output the patches to the
<code>psuh/
</code>
1975 directory, alongside the v1 patches. Using a single directory makes it easy to
1976 refer to the old v1 patches while proofreading the v2 patches, but you will need
1977 to be careful to send out only the v2 patches. We will use a pattern like
1978 <code>psuh/v2-
</code>*.
<code>patch
</code> (not
<code>psuh/
</code>*.
<code>patch
</code>, which would match v1 and v2 patches).
</p>
1980 <div class=
"paragraph">
1981 <p>Edit your cover letter again. Now is a good time to mention what
’s different
1982 between your last version and now, if it
’s something significant. You do not
1983 need the exact same body in your second cover letter; focus on explaining to
1984 reviewers the changes you
’ve made that may not be as visible.
</p>
1986 <div class=
"paragraph">
1987 <p>You will also need to go and find the Message-ID of your previous cover letter.
1988 You can either note it when you send the first series, from the output of
<code>git
</code>
1989 <code>send-email
</code>, or you can look it up on the
1990 <a href=
"https://lore.kernel.org/git">mailing list
</a>. Find your cover letter in the
1991 archives, click on it, then click
"permalink" or
"raw" to reveal the Message-ID
1992 header. It should match:
</p>
1994 <div class=
"listingblock">
1995 <div class=
"content">
1996 <pre>Message-ID:
<foo
.12345.author@example.com
></pre>
1999 <div class=
"paragraph">
2000 <p>Your Message-ID is
<foo.
<code>12345.author@example.com
</code>>. This example will be used
2001 below as well; make sure to replace it with the correct Message-ID for your
2002 <strong>previous cover letter
</strong> - that is, if you
’re sending v2, use the Message-ID
2003 from v1; if you
’re sending v3, use the Message-ID from v2.
</p>
2005 <div class=
"paragraph">
2006 <p>While you
’re looking at the email, you should also note who is CC
’d, as it
’s
2007 common practice in the mailing list to keep all CCs on a thread. You can add
2008 these CC lines directly to your cover letter with a line like so in the header
2009 (before the Subject line):
</p>
2011 <div class=
"listingblock">
2012 <div class=
"content">
2013 <pre>CC: author@example.com, Othe R
<other@example.com
></pre>
2016 <div class=
"paragraph">
2017 <p>Now send the emails again, paying close attention to which messages you pass in
2020 <div class=
"listingblock">
2021 <div class=
"content">
2022 <pre>$ git send-email --to=target@example.com
2023 --in-reply-to=
"<foo.12345.author@example.com>"
2024 psuh/v2-*.patch
</pre>
2029 <h3 id=
"single-patch"><a class=
"anchor" href=
"#single-patch"></a>Bonus Chapter: One-Patch Changes
</h3>
2030 <div class=
"paragraph">
2031 <p>In some cases, your very small change may consist of only one patch. When that
2032 happens, you only need to send one email. Your commit message should already be
2033 meaningful and explain at a high level the purpose (what is happening and why)
2034 of your patch, but if you need to supply even more context, you can do so below
2035 the
<code>---
</code> in your patch. Take the example below, which was generated with
<code>git
</code>
2036 <code>format-patch
</code> on a single commit, and then edited to add the content between
2037 the
<code>---
</code> and the diffstat.
</p>
2039 <div class=
"listingblock">
2040 <div class=
"content">
2041 <pre>From
1345bbb3f7ac74abde040c12e737204689a72723 Mon Sep
17 00:
00:
00 2001
2042 From: A U Thor
<author@example.com
>
2043 Date: Thu,
18 Apr
2019 15:
11:
02 -
0700
2044 Subject: [PATCH] README: change the grammar
2046 I think it looks better this way. This part of the commit message will
2047 end up in the commit-log.
2049 Signed-off-by: A U Thor
<author@example.com
>
2051 Let's have a wild discussion about grammar on the mailing list. This
2052 part of my email will never end up in the commit log. Here is where I
2053 can add additional context to the mailing list about my intent, outside
2054 of the context of the commit log. This section was added after `git
2055 format-patch` was run, by editing the patch file in a text editor.
2058 1 file changed,
1 insertion(+),
1 deletion(-)
2060 diff --git a/README.md b/README.md
2061 index
88f126184c.
.38da593a60
100644
2065 Git - fast, scalable, distributed revision control system
2066 =========================================================
2068 -Git is a fast, scalable, distributed revision control system with an
2069 +Git is a fast, scalable, and distributed revision control system with an
2070 unusually rich command set that provides both high-level operations
2071 and full access to internals.
2074 2.21.0.392.gf8f6787159e-goog
</pre>
2081 <h2 id=
"now-what"><a class=
"anchor" href=
"#now-what"></a>My Patch Got Emailed - Now What?
</h2>
2082 <div class=
"sectionbody">
2083 <div class=
"paragraph">
2084 <p>Please give reviewers enough time to process your initial patch before
2085 sending an updated version. That is, resist the temptation to send a new
2086 version immediately, because others may have already started reviewing
2087 your initial version.
</p>
2089 <div class=
"paragraph">
2090 <p>While waiting for review comments, you may find mistakes in your initial
2091 patch, or perhaps realize a different and better way to achieve the goal
2092 of the patch. In this case you may communicate your findings to other
2093 reviewers as follows:
</p>
2098 <p>If the mistakes you found are minor, send a reply to your patch as if
2099 you were a reviewer and mention that you will fix them in an
2100 updated version.
</p>
2103 <p>On the other hand, if you think you want to change the course so
2104 drastically that reviews on the initial patch would be a waste of
2105 time (for everyone involved), retract the patch immediately with
2106 a reply like
"I am working on a much better approach, so please
2107 ignore this patch and wait for the updated version."</p>
2111 <div class=
"paragraph">
2112 <p>Now, the above is a good practice if you sent your initial patch
2113 prematurely without polish. But a better approach of course is to avoid
2114 sending your patch prematurely in the first place.
</p>
2116 <div class=
"paragraph">
2117 <p>Please be considerate of the time needed by reviewers to examine each
2118 new version of your patch. Rather than seeing the initial version right
2119 now (followed by several
"oops, I like this version better than the
2120 previous one" patches over
2 days), reviewers would strongly prefer if a
2121 single polished version came
2 days later instead, and that version with
2122 fewer mistakes were the only one they would need to review.
</p>
2125 <h3 id=
"reviewing"><a class=
"anchor" href=
"#reviewing"></a>Responding to Reviews
</h3>
2126 <div class=
"paragraph">
2127 <p>After a few days, you will hopefully receive a reply to your patchset with some
2128 comments. Woohoo! Now you can get back to work.
</p>
2130 <div class=
"paragraph">
2131 <p>It
’s good manners to reply to each comment, notifying the reviewer that you have
2132 made the change suggested, feel the original is better, or that the comment
2133 inspired you to do something a new way which is superior to both the original
2134 and the suggested change. This way reviewers don
’t need to inspect your v2 to
2135 figure out whether you implemented their comment or not.
</p>
2137 <div class=
"paragraph">
2138 <p>Reviewers may ask you about what you wrote in the patchset, either in
2139 the proposed commit log message or in the changes themselves. You
2140 should answer these questions in your response messages, but often the
2141 reason why reviewers asked these questions to understand what you meant
2142 to write is because your patchset needed clarification to be understood.
</p>
2144 <div class=
"paragraph">
2145 <p>Do not be satisfied by just answering their questions in your response
2146 and hear them say that they now understand what you wanted to say.
2147 Update your patches to clarify the points reviewers had trouble with,
2148 and prepare your v2; the words you used to explain your v1 to answer
2149 reviewers' questions may be useful thing to use. Your goal is to make
2150 your v2 clear enough so that it becomes unnecessary for you to give the
2151 same explanation to the next person who reads it.
</p>
2153 <div class=
"paragraph">
2154 <p>If you are going to push back on a comment, be polite and explain why you feel
2155 your original is better; be prepared that the reviewer may still disagree with
2156 you, and the rest of the community may weigh in on one side or the other. As
2157 with all code reviews, it
’s important to keep an open mind to doing something a
2158 different way than you originally planned; other reviewers have a different
2159 perspective on the project than you do, and may be thinking of a valid side
2160 effect which had not occurred to you. It is always okay to ask for clarification
2161 if you aren
’t sure why a change was suggested, or what the reviewer is asking
2164 <div class=
"paragraph">
2165 <p>Make sure your email client has a plaintext email mode and it is turned on; the
2166 Git list rejects HTML email. Please also follow the mailing list etiquette
2168 <a href=
"https://kernel.googlesource.com/pub/scm/git/git/+/todo/MaintNotes">Maintainer
’s
2169 Note
</a>, which are similar to etiquette rules in most open source communities
2170 surrounding bottom-posting and inline replies.
</p>
2172 <div class=
"paragraph">
2173 <p>When you
’re making changes to your code, it is cleanest - that is, the resulting
2174 commits are easiest to look at - if you use
<code>git
</code> <code>rebase
</code> <code>-i
</code> (interactive
2175 rebase). Take a look at this
2176 <a href=
"https://www.oreilly.com/library/view/git-pocket-guide/9781449327507/ch10.html">overview
</a>
2177 from O
’Reilly. The general idea is to modify each commit which requires changes;
2178 this way, instead of having a patch A with a mistake, a patch B which was fine
2179 and required no upstream reviews in v1, and a patch C which fixes patch A for
2180 v2, you can just ship a v2 with a correct patch A and correct patch B. This is
2181 changing history, but since it
’s local history which you haven
’t shared with
2182 anyone, that is okay for now! (Later, it may not make sense to do this; take a
2183 look at the section below this one for some context.)
</p>
2187 <h3 id=
"after-approval"><a class=
"anchor" href=
"#after-approval"></a>After Review Approval
</h3>
2188 <div class=
"paragraph">
2189 <p>The Git project has four integration branches:
<code>seen
</code>,
<code>next
</code>,
<code>master
</code>, and
2190 <code>maint
</code>. Your change will be placed into
<code>seen
</code> fairly early on by the maintainer
2191 while it is still in the review process; from there, when it is ready for wider
2192 testing, it will be merged into
<code>next
</code>. Plenty of early testers use
<code>next
</code> and
2193 may report issues. Eventually, changes in
<code>next
</code> will make it to
<code>master
</code>,
2194 which is typically considered stable. Finally, when a new release is cut,
2195 <code>maint
</code> is used to base bugfixes onto. As mentioned at the beginning of this
2196 document, you can read
<code>Documents/SubmittingPatches
</code> for some more info about
2197 the use of the various integration branches.
</p>
2199 <div class=
"paragraph">
2200 <p>Back to now: your code has been lauded by the upstream reviewers. It is perfect.
2201 It is ready to be accepted. You don
’t need to do anything else; the maintainer
2202 will merge your topic branch to
<code>next
</code> and life is good.
</p>
2204 <div class=
"paragraph">
2205 <p>However, if you discover it isn
’t so perfect after this point, you may need to
2206 take some special steps depending on where you are in the process.
</p>
2208 <div class=
"paragraph">
2209 <p>If the maintainer has announced in the
"What’s cooking in git.git" email that
2210 your topic is marked for
<code>next
</code> - that is, that they plan to merge it to
<code>next
</code>
2211 but have not yet done so - you should send an email asking the maintainer to
2212 wait a little longer:
"I’ve sent v4 of my series and you marked it for <code>next</code>,
2213 but I need to change this and that - please wait for v5 before you merge it."</p>
2215 <div class=
"paragraph">
2216 <p>If the topic has already been merged to
<code>next
</code>, rather than modifying your
2217 patches with
<code>git
</code> <code>rebase
</code> <code>-i
</code>, you should make further changes incrementally -
2218 that is, with another commit, based on top of the maintainer
’s topic branch as
2219 detailed in
<a href=
"https://github.com/gitster/git" class=
"bare">https://github.com/gitster/git
</a>. Your work is still in the same topic
2220 but is now incremental, rather than a wholesale rewrite of the topic branch.
</p>
2222 <div class=
"paragraph">
2223 <p>The topic branches in the maintainer
’s GitHub are mirrored in GitGitGadget, so
2224 if you
’re sending your reviews out that way, you should be sure to open your PR
2225 against the appropriate GitGitGadget/Git branch.
</p>
2227 <div class=
"paragraph">
2228 <p>If you
’re using
<code>git
</code> <code>send-email
</code>, you can use it the same way as before, but you
2229 should generate your diffs from
<em><topic
></em><code>..
</code><em><mybranch
></em> and base your work on
2230 <em><topic
></em> instead of
<code>master
</code>.
</p>
2236 <div id=
"footnotes">
2238 <div class=
"footnote" id=
"_footnotedef_1">
2239 <a href=
"#_footnoteref_1">1</a>. Scripts under `contrib/` are not part of the core `git` binary and must be called directly. Clone the Git codebase and run `perl contrib/contacts/git-contacts`.
2243 <div id=
"footer-text">
2244 Last updated
2024-
05-
02 02:
56:
52 +
0900