Junio C Hamano | 944ce25 | 2018-05-30 22:25:26 | [diff] [blame] | 1 | <?xml version="1.0" encoding="UTF-8"?> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 2 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" |
| 3 | "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> |
| 4 | <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> |
| 5 | <head> |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 6 | <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" /> |
Junio C Hamano | 944ce25 | 2018-05-30 22:25:26 | [diff] [blame] | 7 | <meta name="generator" content="AsciiDoc 8.6.10" /> |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 8 | <title>gittutorial(7)</title> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 9 | <style type="text/css"> |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 10 | /* Shared CSS for AsciiDoc xhtml11 and html5 backends */ |
| 11 | |
| 12 | /* Default font. */ |
| 13 | body { |
| 14 | font-family: Georgia,serif; |
| 15 | } |
| 16 | |
| 17 | /* Title font. */ |
| 18 | h1, h2, h3, h4, h5, h6, |
| 19 | div.title, caption.title, |
| 20 | thead, p.table.header, |
| 21 | #toctitle, |
| 22 | #author, #revnumber, #revdate, #revremark, |
| 23 | #footer { |
| 24 | font-family: Arial,Helvetica,sans-serif; |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 25 | } |
| 26 | |
| 27 | body { |
| 28 | margin: 1em 5% 1em 5%; |
| 29 | } |
| 30 | |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 31 | a { |
| 32 | color: blue; |
| 33 | text-decoration: underline; |
| 34 | } |
| 35 | a:visited { |
| 36 | color: fuchsia; |
| 37 | } |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 38 | |
| 39 | em { |
| 40 | font-style: italic; |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 41 | color: navy; |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 42 | } |
| 43 | |
| 44 | strong { |
| 45 | font-weight: bold; |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 46 | color: #083194; |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 47 | } |
| 48 | |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 49 | h1, h2, h3, h4, h5, h6 { |
| 50 | color: #527bbd; |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 51 | margin-top: 1.2em; |
| 52 | margin-bottom: 0.5em; |
| 53 | line-height: 1.3; |
| 54 | } |
| 55 | |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 56 | h1, h2, h3 { |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 57 | border-bottom: 2px solid silver; |
| 58 | } |
| 59 | h2 { |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 60 | padding-top: 0.5em; |
| 61 | } |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 62 | h3 { |
| 63 | float: left; |
| 64 | } |
| 65 | h3 + * { |
| 66 | clear: left; |
| 67 | } |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 68 | h5 { |
| 69 | font-size: 1.0em; |
| 70 | } |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 71 | |
| 72 | div.sectionbody { |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 73 | margin-left: 0; |
| 74 | } |
| 75 | |
| 76 | hr { |
| 77 | border: 1px solid silver; |
| 78 | } |
| 79 | |
| 80 | p { |
| 81 | margin-top: 0.5em; |
| 82 | margin-bottom: 0.5em; |
| 83 | } |
| 84 | |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 85 | ul, ol, li > p { |
| 86 | margin-top: 0; |
| 87 | } |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 88 | ul > li { color: #aaa; } |
| 89 | ul > li > * { color: black; } |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 90 | |
Junio C Hamano | 446e30b | 2014-10-16 21:30:32 | [diff] [blame] | 91 | .monospaced, code, pre { |
| 92 | font-family: "Courier New", Courier, monospace; |
| 93 | font-size: inherit; |
| 94 | color: navy; |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 95 | padding: 0; |
| 96 | margin: 0; |
| 97 | } |
Junio C Hamano | 446e30b | 2014-10-16 21:30:32 | [diff] [blame] | 98 | pre { |
| 99 | white-space: pre-wrap; |
| 100 | } |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 101 | |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 102 | #author { |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 103 | color: #527bbd; |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 104 | font-weight: bold; |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 105 | font-size: 1.1em; |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 106 | } |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 107 | #email { |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 108 | } |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 109 | #revnumber, #revdate, #revremark { |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 110 | } |
| 111 | |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 112 | #footer { |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 113 | font-size: small; |
| 114 | border-top: 2px solid silver; |
| 115 | padding-top: 0.5em; |
| 116 | margin-top: 4.0em; |
| 117 | } |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 118 | #footer-text { |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 119 | float: left; |
| 120 | padding-bottom: 0.5em; |
| 121 | } |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 122 | #footer-badges { |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 123 | float: right; |
| 124 | padding-bottom: 0.5em; |
| 125 | } |
| 126 | |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 127 | #preamble { |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 128 | margin-top: 1.5em; |
| 129 | margin-bottom: 1.5em; |
| 130 | } |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 131 | div.imageblock, div.exampleblock, div.verseblock, |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 132 | div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock, |
| 133 | div.admonitionblock { |
Junio C Hamano | 7bd050f | 2011-09-22 06:32:22 | [diff] [blame] | 134 | margin-top: 1.0em; |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 135 | margin-bottom: 1.5em; |
| 136 | } |
| 137 | div.admonitionblock { |
Junio C Hamano | 7bd050f | 2011-09-22 06:32:22 | [diff] [blame] | 138 | margin-top: 2.0em; |
| 139 | margin-bottom: 2.0em; |
| 140 | margin-right: 10%; |
| 141 | color: #606060; |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 142 | } |
| 143 | |
| 144 | div.content { /* Block element content. */ |
| 145 | padding: 0; |
| 146 | } |
| 147 | |
| 148 | /* Block element titles. */ |
| 149 | div.title, caption.title { |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 150 | color: #527bbd; |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 151 | font-weight: bold; |
| 152 | text-align: left; |
| 153 | margin-top: 1.0em; |
| 154 | margin-bottom: 0.5em; |
| 155 | } |
| 156 | div.title + * { |
| 157 | margin-top: 0; |
| 158 | } |
| 159 | |
| 160 | td div.title:first-child { |
| 161 | margin-top: 0.0em; |
| 162 | } |
| 163 | div.content div.title:first-child { |
| 164 | margin-top: 0.0em; |
| 165 | } |
| 166 | div.content + div.title { |
| 167 | margin-top: 0.0em; |
| 168 | } |
| 169 | |
| 170 | div.sidebarblock > div.content { |
| 171 | background: #ffffee; |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 172 | border: 1px solid #dddddd; |
| 173 | border-left: 4px solid #f0f0f0; |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 174 | padding: 0.5em; |
| 175 | } |
| 176 | |
| 177 | div.listingblock > div.content { |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 178 | border: 1px solid #dddddd; |
| 179 | border-left: 5px solid #f0f0f0; |
| 180 | background: #f8f8f8; |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 181 | padding: 0.5em; |
| 182 | } |
| 183 | |
Junio C Hamano | 7bd050f | 2011-09-22 06:32:22 | [diff] [blame] | 184 | div.quoteblock, div.verseblock { |
| 185 | padding-left: 1.0em; |
| 186 | margin-left: 1.0em; |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 187 | margin-right: 10%; |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 188 | border-left: 5px solid #f0f0f0; |
| 189 | color: #888; |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 190 | } |
Junio C Hamano | 7bd050f | 2011-09-22 06:32:22 | [diff] [blame] | 191 | |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 192 | div.quoteblock > div.attribution { |
| 193 | padding-top: 0.5em; |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 194 | text-align: right; |
| 195 | } |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 196 | |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 197 | div.verseblock > pre.content { |
| 198 | font-family: inherit; |
| 199 | font-size: inherit; |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 200 | } |
| 201 | div.verseblock > div.attribution { |
| 202 | padding-top: 0.75em; |
| 203 | text-align: left; |
| 204 | } |
| 205 | /* DEPRECATED: Pre version 8.2.7 verse style literal block. */ |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 206 | div.verseblock + div.attribution { |
| 207 | text-align: left; |
| 208 | } |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 209 | |
| 210 | div.admonitionblock .icon { |
| 211 | vertical-align: top; |
| 212 | font-size: 1.1em; |
| 213 | font-weight: bold; |
| 214 | text-decoration: underline; |
| 215 | color: #527bbd; |
| 216 | padding-right: 0.5em; |
| 217 | } |
| 218 | div.admonitionblock td.content { |
| 219 | padding-left: 0.5em; |
Junio C Hamano | 7bd050f | 2011-09-22 06:32:22 | [diff] [blame] | 220 | border-left: 3px solid #dddddd; |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 221 | } |
| 222 | |
| 223 | div.exampleblock > div.content { |
Junio C Hamano | 7bd050f | 2011-09-22 06:32:22 | [diff] [blame] | 224 | border-left: 3px solid #dddddd; |
| 225 | padding-left: 0.5em; |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 226 | } |
| 227 | |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 228 | div.imageblock div.content { padding-left: 0; } |
Junio C Hamano | 446e30b | 2014-10-16 21:30:32 | [diff] [blame] | 229 | span.image img { border-style: none; vertical-align: text-bottom; } |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 230 | a.image:visited { color: white; } |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 231 | |
| 232 | dl { |
| 233 | margin-top: 0.8em; |
| 234 | margin-bottom: 0.8em; |
| 235 | } |
| 236 | dt { |
| 237 | margin-top: 0.5em; |
| 238 | margin-bottom: 0; |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 239 | font-style: normal; |
| 240 | color: navy; |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 241 | } |
| 242 | dd > *:first-child { |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 243 | margin-top: 0.1em; |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 244 | } |
| 245 | |
| 246 | ul, ol { |
| 247 | list-style-position: outside; |
| 248 | } |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 249 | ol.arabic { |
| 250 | list-style-type: decimal; |
| 251 | } |
| 252 | ol.loweralpha { |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 253 | list-style-type: lower-alpha; |
| 254 | } |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 255 | ol.upperalpha { |
| 256 | list-style-type: upper-alpha; |
| 257 | } |
| 258 | ol.lowerroman { |
| 259 | list-style-type: lower-roman; |
| 260 | } |
| 261 | ol.upperroman { |
| 262 | list-style-type: upper-roman; |
| 263 | } |
| 264 | |
| 265 | div.compact ul, div.compact ol, |
| 266 | div.compact p, div.compact p, |
| 267 | div.compact div, div.compact div { |
| 268 | margin-top: 0.1em; |
| 269 | margin-bottom: 0.1em; |
| 270 | } |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 271 | |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 272 | tfoot { |
| 273 | font-weight: bold; |
| 274 | } |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 275 | td > div.verse { |
| 276 | white-space: pre; |
| 277 | } |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 278 | |
| 279 | div.hdlist { |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 280 | margin-top: 0.8em; |
| 281 | margin-bottom: 0.8em; |
| 282 | } |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 283 | div.hdlist tr { |
| 284 | padding-bottom: 15px; |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 285 | } |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 286 | dt.hdlist1.strong, td.hdlist1.strong { |
| 287 | font-weight: bold; |
| 288 | } |
| 289 | td.hdlist1 { |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 290 | vertical-align: top; |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 291 | font-style: normal; |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 292 | padding-right: 0.8em; |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 293 | color: navy; |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 294 | } |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 295 | td.hdlist2 { |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 296 | vertical-align: top; |
| 297 | } |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 298 | div.hdlist.compact tr { |
| 299 | margin: 0; |
| 300 | padding-bottom: 0; |
| 301 | } |
| 302 | |
| 303 | .comment { |
| 304 | background: yellow; |
| 305 | } |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 306 | |
Junio C Hamano | 7bd050f | 2011-09-22 06:32:22 | [diff] [blame] | 307 | .footnote, .footnoteref { |
| 308 | font-size: 0.8em; |
| 309 | } |
| 310 | |
| 311 | span.footnote, span.footnoteref { |
| 312 | vertical-align: super; |
| 313 | } |
| 314 | |
| 315 | #footnotes { |
| 316 | margin: 20px 0 20px 0; |
| 317 | padding: 7px 0 0 0; |
| 318 | } |
| 319 | |
| 320 | #footnotes div.footnote { |
| 321 | margin: 0 0 5px 0; |
| 322 | } |
| 323 | |
| 324 | #footnotes hr { |
| 325 | border: none; |
| 326 | border-top: 1px solid silver; |
| 327 | height: 1px; |
| 328 | text-align: left; |
| 329 | margin-left: 0; |
| 330 | width: 20%; |
| 331 | min-width: 100px; |
| 332 | } |
| 333 | |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 334 | div.colist td { |
| 335 | padding-right: 0.5em; |
| 336 | padding-bottom: 0.3em; |
| 337 | vertical-align: top; |
| 338 | } |
| 339 | div.colist td img { |
| 340 | margin-top: 0.3em; |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 341 | } |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 342 | |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 343 | @media print { |
| 344 | #footer-badges { display: none; } |
| 345 | } |
| 346 | |
| 347 | #toc { |
Junio C Hamano | 7bd050f | 2011-09-22 06:32:22 | [diff] [blame] | 348 | margin-bottom: 2.5em; |
| 349 | } |
| 350 | |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 351 | #toctitle { |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 352 | color: #527bbd; |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 353 | font-size: 1.1em; |
| 354 | font-weight: bold; |
| 355 | margin-top: 1.0em; |
| 356 | margin-bottom: 0.1em; |
| 357 | } |
| 358 | |
Junio C Hamano | 446e30b | 2014-10-16 21:30:32 | [diff] [blame] | 359 | div.toclevel0, div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 { |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 360 | margin-top: 0; |
| 361 | margin-bottom: 0; |
| 362 | } |
| 363 | div.toclevel2 { |
| 364 | margin-left: 2em; |
| 365 | font-size: 0.9em; |
| 366 | } |
| 367 | div.toclevel3 { |
| 368 | margin-left: 4em; |
| 369 | font-size: 0.9em; |
| 370 | } |
| 371 | div.toclevel4 { |
| 372 | margin-left: 6em; |
| 373 | font-size: 0.9em; |
| 374 | } |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 375 | |
| 376 | span.aqua { color: aqua; } |
| 377 | span.black { color: black; } |
| 378 | span.blue { color: blue; } |
| 379 | span.fuchsia { color: fuchsia; } |
| 380 | span.gray { color: gray; } |
| 381 | span.green { color: green; } |
| 382 | span.lime { color: lime; } |
| 383 | span.maroon { color: maroon; } |
| 384 | span.navy { color: navy; } |
| 385 | span.olive { color: olive; } |
| 386 | span.purple { color: purple; } |
| 387 | span.red { color: red; } |
| 388 | span.silver { color: silver; } |
| 389 | span.teal { color: teal; } |
| 390 | span.white { color: white; } |
| 391 | span.yellow { color: yellow; } |
| 392 | |
| 393 | span.aqua-background { background: aqua; } |
| 394 | span.black-background { background: black; } |
| 395 | span.blue-background { background: blue; } |
| 396 | span.fuchsia-background { background: fuchsia; } |
| 397 | span.gray-background { background: gray; } |
| 398 | span.green-background { background: green; } |
| 399 | span.lime-background { background: lime; } |
| 400 | span.maroon-background { background: maroon; } |
| 401 | span.navy-background { background: navy; } |
| 402 | span.olive-background { background: olive; } |
| 403 | span.purple-background { background: purple; } |
| 404 | span.red-background { background: red; } |
| 405 | span.silver-background { background: silver; } |
| 406 | span.teal-background { background: teal; } |
| 407 | span.white-background { background: white; } |
| 408 | span.yellow-background { background: yellow; } |
| 409 | |
| 410 | span.big { font-size: 2em; } |
| 411 | span.small { font-size: 0.6em; } |
| 412 | |
| 413 | span.underline { text-decoration: underline; } |
| 414 | span.overline { text-decoration: overline; } |
| 415 | span.line-through { text-decoration: line-through; } |
| 416 | |
Junio C Hamano | 446e30b | 2014-10-16 21:30:32 | [diff] [blame] | 417 | div.unbreakable { page-break-inside: avoid; } |
| 418 | |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 419 | |
| 420 | /* |
| 421 | * xhtml11 specific |
| 422 | * |
| 423 | * */ |
| 424 | |
| 425 | div.tableblock { |
| 426 | margin-top: 1.0em; |
| 427 | margin-bottom: 1.5em; |
| 428 | } |
| 429 | div.tableblock > table { |
| 430 | border: 3px solid #527bbd; |
| 431 | } |
| 432 | thead, p.table.header { |
| 433 | font-weight: bold; |
| 434 | color: #527bbd; |
| 435 | } |
| 436 | p.table { |
| 437 | margin-top: 0; |
| 438 | } |
| 439 | /* Because the table frame attribute is overriden by CSS in most browsers. */ |
| 440 | div.tableblock > table[frame="void"] { |
| 441 | border-style: none; |
| 442 | } |
| 443 | div.tableblock > table[frame="hsides"] { |
| 444 | border-left-style: none; |
| 445 | border-right-style: none; |
| 446 | } |
| 447 | div.tableblock > table[frame="vsides"] { |
| 448 | border-top-style: none; |
| 449 | border-bottom-style: none; |
| 450 | } |
| 451 | |
| 452 | |
| 453 | /* |
| 454 | * html5 specific |
| 455 | * |
| 456 | * */ |
| 457 | |
| 458 | table.tableblock { |
| 459 | margin-top: 1.0em; |
| 460 | margin-bottom: 1.5em; |
| 461 | } |
| 462 | thead, p.tableblock.header { |
| 463 | font-weight: bold; |
| 464 | color: #527bbd; |
| 465 | } |
| 466 | p.tableblock { |
| 467 | margin-top: 0; |
| 468 | } |
| 469 | table.tableblock { |
| 470 | border-width: 3px; |
| 471 | border-spacing: 0px; |
| 472 | border-style: solid; |
| 473 | border-color: #527bbd; |
| 474 | border-collapse: collapse; |
| 475 | } |
| 476 | th.tableblock, td.tableblock { |
| 477 | border-width: 1px; |
| 478 | padding: 4px; |
| 479 | border-style: solid; |
| 480 | border-color: #527bbd; |
| 481 | } |
| 482 | |
| 483 | table.tableblock.frame-topbot { |
| 484 | border-left-style: hidden; |
| 485 | border-right-style: hidden; |
| 486 | } |
| 487 | table.tableblock.frame-sides { |
| 488 | border-top-style: hidden; |
| 489 | border-bottom-style: hidden; |
| 490 | } |
| 491 | table.tableblock.frame-none { |
| 492 | border-style: hidden; |
| 493 | } |
| 494 | |
| 495 | th.tableblock.halign-left, td.tableblock.halign-left { |
| 496 | text-align: left; |
| 497 | } |
| 498 | th.tableblock.halign-center, td.tableblock.halign-center { |
| 499 | text-align: center; |
| 500 | } |
| 501 | th.tableblock.halign-right, td.tableblock.halign-right { |
| 502 | text-align: right; |
| 503 | } |
| 504 | |
| 505 | th.tableblock.valign-top, td.tableblock.valign-top { |
| 506 | vertical-align: top; |
| 507 | } |
| 508 | th.tableblock.valign-middle, td.tableblock.valign-middle { |
| 509 | vertical-align: middle; |
| 510 | } |
| 511 | th.tableblock.valign-bottom, td.tableblock.valign-bottom { |
| 512 | vertical-align: bottom; |
| 513 | } |
| 514 | |
| 515 | |
| 516 | /* |
| 517 | * manpage specific |
| 518 | * |
| 519 | * */ |
| 520 | |
| 521 | body.manpage h1 { |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 522 | padding-top: 0.5em; |
| 523 | padding-bottom: 0.5em; |
| 524 | border-top: 2px solid silver; |
| 525 | border-bottom: 2px solid silver; |
| 526 | } |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 527 | body.manpage h2 { |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 528 | border-style: none; |
| 529 | } |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 530 | body.manpage div.sectionbody { |
| 531 | margin-left: 3em; |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 532 | } |
| 533 | |
| 534 | @media print { |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 535 | body.manpage div#toc { display: none; } |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 536 | } |
Junio C Hamano | 446e30b | 2014-10-16 21:30:32 | [diff] [blame] | 537 | |
| 538 | |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 539 | </style> |
Junio C Hamano | 7bd050f | 2011-09-22 06:32:22 | [diff] [blame] | 540 | <script type="text/javascript"> |
| 541 | /*<![CDATA[*/ |
Junio C Hamano | 7bd050f | 2011-09-22 06:32:22 | [diff] [blame] | 542 | var asciidoc = { // Namespace. |
| 543 | |
| 544 | ///////////////////////////////////////////////////////////////////// |
| 545 | // Table Of Contents generator |
| 546 | ///////////////////////////////////////////////////////////////////// |
| 547 | |
| 548 | /* Author: Mihai Bazon, September 2002 |
| 549 | * http://students.infoiasi.ro/~mishoo |
| 550 | * |
| 551 | * Table Of Content generator |
| 552 | * Version: 0.4 |
| 553 | * |
| 554 | * Feel free to use this script under the terms of the GNU General Public |
| 555 | * License, as long as you do not remove or alter this notice. |
| 556 | */ |
| 557 | |
| 558 | /* modified by Troy D. Hanson, September 2006. License: GPL */ |
| 559 | /* modified by Stuart Rackham, 2006, 2009. License: GPL */ |
| 560 | |
| 561 | // toclevels = 1..4. |
| 562 | toc: function (toclevels) { |
| 563 | |
| 564 | function getText(el) { |
| 565 | var text = ""; |
| 566 | for (var i = el.firstChild; i != null; i = i.nextSibling) { |
| 567 | if (i.nodeType == 3 /* Node.TEXT_NODE */) // IE doesn't speak constants. |
| 568 | text += i.data; |
| 569 | else if (i.firstChild != null) |
| 570 | text += getText(i); |
| 571 | } |
| 572 | return text; |
| 573 | } |
| 574 | |
| 575 | function TocEntry(el, text, toclevel) { |
| 576 | this.element = el; |
| 577 | this.text = text; |
| 578 | this.toclevel = toclevel; |
| 579 | } |
| 580 | |
| 581 | function tocEntries(el, toclevels) { |
| 582 | var result = new Array; |
Junio C Hamano | 446e30b | 2014-10-16 21:30:32 | [diff] [blame] | 583 | var re = new RegExp('[hH]([1-'+(toclevels+1)+'])'); |
Junio C Hamano | 7bd050f | 2011-09-22 06:32:22 | [diff] [blame] | 584 | // Function that scans the DOM tree for header elements (the DOM2 |
| 585 | // nodeIterator API would be a better technique but not supported by all |
| 586 | // browsers). |
| 587 | var iterate = function (el) { |
| 588 | for (var i = el.firstChild; i != null; i = i.nextSibling) { |
| 589 | if (i.nodeType == 1 /* Node.ELEMENT_NODE */) { |
| 590 | var mo = re.exec(i.tagName); |
| 591 | if (mo && (i.getAttribute("class") || i.getAttribute("className")) != "float") { |
| 592 | result[result.length] = new TocEntry(i, getText(i), mo[1]-1); |
| 593 | } |
| 594 | iterate(i); |
| 595 | } |
| 596 | } |
| 597 | } |
| 598 | iterate(el); |
| 599 | return result; |
| 600 | } |
| 601 | |
| 602 | var toc = document.getElementById("toc"); |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 603 | if (!toc) { |
| 604 | return; |
| 605 | } |
| 606 | |
| 607 | // Delete existing TOC entries in case we're reloading the TOC. |
| 608 | var tocEntriesToRemove = []; |
| 609 | var i; |
| 610 | for (i = 0; i < toc.childNodes.length; i++) { |
| 611 | var entry = toc.childNodes[i]; |
Junio C Hamano | 446e30b | 2014-10-16 21:30:32 | [diff] [blame] | 612 | if (entry.nodeName.toLowerCase() == 'div' |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 613 | && entry.getAttribute("class") |
| 614 | && entry.getAttribute("class").match(/^toclevel/)) |
| 615 | tocEntriesToRemove.push(entry); |
| 616 | } |
| 617 | for (i = 0; i < tocEntriesToRemove.length; i++) { |
| 618 | toc.removeChild(tocEntriesToRemove[i]); |
| 619 | } |
| 620 | |
| 621 | // Rebuild TOC entries. |
Junio C Hamano | 7bd050f | 2011-09-22 06:32:22 | [diff] [blame] | 622 | var entries = tocEntries(document.getElementById("content"), toclevels); |
| 623 | for (var i = 0; i < entries.length; ++i) { |
| 624 | var entry = entries[i]; |
| 625 | if (entry.element.id == "") |
| 626 | entry.element.id = "_toc_" + i; |
| 627 | var a = document.createElement("a"); |
| 628 | a.href = "#" + entry.element.id; |
| 629 | a.appendChild(document.createTextNode(entry.text)); |
| 630 | var div = document.createElement("div"); |
| 631 | div.appendChild(a); |
| 632 | div.className = "toclevel" + entry.toclevel; |
| 633 | toc.appendChild(div); |
| 634 | } |
| 635 | if (entries.length == 0) |
| 636 | toc.parentNode.removeChild(toc); |
| 637 | }, |
| 638 | |
| 639 | |
| 640 | ///////////////////////////////////////////////////////////////////// |
| 641 | // Footnotes generator |
| 642 | ///////////////////////////////////////////////////////////////////// |
| 643 | |
| 644 | /* Based on footnote generation code from: |
| 645 | * http://www.brandspankingnew.net/archive/2005/07/format_footnote.html |
| 646 | */ |
| 647 | |
| 648 | footnotes: function () { |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 649 | // Delete existing footnote entries in case we're reloading the footnodes. |
| 650 | var i; |
Junio C Hamano | 7bd050f | 2011-09-22 06:32:22 | [diff] [blame] | 651 | var noteholder = document.getElementById("footnotes"); |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 652 | if (!noteholder) { |
| 653 | return; |
| 654 | } |
| 655 | var entriesToRemove = []; |
| 656 | for (i = 0; i < noteholder.childNodes.length; i++) { |
| 657 | var entry = noteholder.childNodes[i]; |
Junio C Hamano | 446e30b | 2014-10-16 21:30:32 | [diff] [blame] | 658 | if (entry.nodeName.toLowerCase() == 'div' && entry.getAttribute("class") == "footnote") |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 659 | entriesToRemove.push(entry); |
| 660 | } |
| 661 | for (i = 0; i < entriesToRemove.length; i++) { |
| 662 | noteholder.removeChild(entriesToRemove[i]); |
| 663 | } |
| 664 | |
| 665 | // Rebuild footnote entries. |
| 666 | var cont = document.getElementById("content"); |
Junio C Hamano | 7bd050f | 2011-09-22 06:32:22 | [diff] [blame] | 667 | var spans = cont.getElementsByTagName("span"); |
| 668 | var refs = {}; |
| 669 | var n = 0; |
| 670 | for (i=0; i<spans.length; i++) { |
| 671 | if (spans[i].className == "footnote") { |
| 672 | n++; |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 673 | var note = spans[i].getAttribute("data-note"); |
| 674 | if (!note) { |
| 675 | // Use [\s\S] in place of . so multi-line matches work. |
| 676 | // Because JavaScript has no s (dotall) regex flag. |
| 677 | note = spans[i].innerHTML.match(/\s*\[([\s\S]*)]\s*/)[1]; |
| 678 | spans[i].innerHTML = |
| 679 | "[<a id='_footnoteref_" + n + "' href='#_footnote_" + n + |
| 680 | "' title='View footnote' class='footnote'>" + n + "</a>]"; |
| 681 | spans[i].setAttribute("data-note", note); |
| 682 | } |
Junio C Hamano | 7bd050f | 2011-09-22 06:32:22 | [diff] [blame] | 683 | noteholder.innerHTML += |
| 684 | "<div class='footnote' id='_footnote_" + n + "'>" + |
| 685 | "<a href='#_footnoteref_" + n + "' title='Return to text'>" + |
| 686 | n + "</a>. " + note + "</div>"; |
Junio C Hamano | 7bd050f | 2011-09-22 06:32:22 | [diff] [blame] | 687 | var id =spans[i].getAttribute("id"); |
| 688 | if (id != null) refs["#"+id] = n; |
| 689 | } |
| 690 | } |
| 691 | if (n == 0) |
| 692 | noteholder.parentNode.removeChild(noteholder); |
| 693 | else { |
| 694 | // Process footnoterefs. |
| 695 | for (i=0; i<spans.length; i++) { |
| 696 | if (spans[i].className == "footnoteref") { |
| 697 | var href = spans[i].getElementsByTagName("a")[0].getAttribute("href"); |
| 698 | href = href.match(/#.*/)[0]; // Because IE return full URL. |
| 699 | n = refs[href]; |
| 700 | spans[i].innerHTML = |
| 701 | "[<a href='#_footnote_" + n + |
| 702 | "' title='View footnote' class='footnote'>" + n + "</a>]"; |
| 703 | } |
| 704 | } |
| 705 | } |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 706 | }, |
| 707 | |
| 708 | install: function(toclevels) { |
| 709 | var timerId; |
| 710 | |
| 711 | function reinstall() { |
| 712 | asciidoc.footnotes(); |
| 713 | if (toclevels) { |
| 714 | asciidoc.toc(toclevels); |
| 715 | } |
| 716 | } |
| 717 | |
| 718 | function reinstallAndRemoveTimer() { |
| 719 | clearInterval(timerId); |
| 720 | reinstall(); |
| 721 | } |
| 722 | |
| 723 | timerId = setInterval(reinstall, 500); |
| 724 | if (document.addEventListener) |
| 725 | document.addEventListener("DOMContentLoaded", reinstallAndRemoveTimer, false); |
| 726 | else |
| 727 | window.onload = reinstallAndRemoveTimer; |
Junio C Hamano | 7bd050f | 2011-09-22 06:32:22 | [diff] [blame] | 728 | } |
| 729 | |
| 730 | } |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 731 | asciidoc.install(); |
Junio C Hamano | 7bd050f | 2011-09-22 06:32:22 | [diff] [blame] | 732 | /*]]>*/ |
| 733 | </script> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 734 | </head> |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 735 | <body class="manpage"> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 736 | <div id="header"> |
| 737 | <h1> |
| 738 | gittutorial(7) Manual Page |
| 739 | </h1> |
| 740 | <h2>NAME</h2> |
| 741 | <div class="sectionbody"> |
| 742 | <p>gittutorial - |
Junio C Hamano | 19a0f4e | 2014-11-18 21:46:36 | [diff] [blame] | 743 | A tutorial introduction to Git |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 744 | </p> |
| 745 | </div> |
| 746 | </div> |
Junio C Hamano | 7bd050f | 2011-09-22 06:32:22 | [diff] [blame] | 747 | <div id="content"> |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 748 | <div class="sect1"> |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 749 | <h2 id="_synopsis">SYNOPSIS</h2> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 750 | <div class="sectionbody"> |
Junio C Hamano | 15567bc | 2011-07-23 00:51:59 | [diff] [blame] | 751 | <div class="verseblock"> |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 752 | <pre class="content">git *</pre> |
| 753 | <div class="attribution"> |
Junio C Hamano | 15567bc | 2011-07-23 00:51:59 | [diff] [blame] | 754 | </div></div> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 755 | </div> |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 756 | </div> |
| 757 | <div class="sect1"> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 758 | <h2 id="_description">DESCRIPTION</h2> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 759 | <div class="sectionbody"> |
Junio C Hamano | 076ffcc | 2013-02-06 05:13:21 | [diff] [blame] | 760 | <div class="paragraph"><p>This tutorial explains how to import a new project into Git, make |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 761 | changes to it, and share changes with other developers.</p></div> |
Junio C Hamano | 076ffcc | 2013-02-06 05:13:21 | [diff] [blame] | 762 | <div class="paragraph"><p>If you are instead primarily interested in using Git to fetch a project, |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 763 | for example, to test the latest version, you may prefer to start with |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 764 | the first two chapters of <a href="user-manual.html">The Git User’s Manual</a>.</p></div> |
| 765 | <div class="paragraph"><p>First, note that you can get documentation for a command such as |
Junio C Hamano | 446e30b | 2014-10-16 21:30:32 | [diff] [blame] | 766 | <code>git log --graph</code> with:</p></div> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 767 | <div class="listingblock"> |
| 768 | <div class="content"> |
Junio C Hamano | 446e30b | 2014-10-16 21:30:32 | [diff] [blame] | 769 | <pre><code>$ man git-log</code></pre> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 770 | </div></div> |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 771 | <div class="paragraph"><p>or:</p></div> |
Junio C Hamano | f66ecee | 2008-11-17 18:25:43 | [diff] [blame] | 772 | <div class="listingblock"> |
| 773 | <div class="content"> |
Junio C Hamano | 446e30b | 2014-10-16 21:30:32 | [diff] [blame] | 774 | <pre><code>$ git help log</code></pre> |
Junio C Hamano | f66ecee | 2008-11-17 18:25:43 | [diff] [blame] | 775 | </div></div> |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 776 | <div class="paragraph"><p>With the latter, you can use the manual viewer of your choice; see |
Junio C Hamano | a28a920 | 2012-06-21 07:08:23 | [diff] [blame] | 777 | <a href="git-help.html">git-help(1)</a> for more information.</p></div> |
Junio C Hamano | 076ffcc | 2013-02-06 05:13:21 | [diff] [blame] | 778 | <div class="paragraph"><p>It is a good idea to introduce yourself to Git with your name and |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 779 | public email address before doing any operation. The easiest |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 780 | way to do so is:</p></div> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 781 | <div class="listingblock"> |
| 782 | <div class="content"> |
Junio C Hamano | 446e30b | 2014-10-16 21:30:32 | [diff] [blame] | 783 | <pre><code>$ git config --global user.name "Your Name Comes Here" |
| 784 | $ git config --global user.email you@yourdomain.example.com</code></pre> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 785 | </div></div> |
| 786 | </div> |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 787 | </div> |
| 788 | <div class="sect1"> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 789 | <h2 id="_importing_a_new_project">Importing a new project</h2> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 790 | <div class="sectionbody"> |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 791 | <div class="paragraph"><p>Assume you have a tarball project.tar.gz with your initial work. You |
Junio C Hamano | 076ffcc | 2013-02-06 05:13:21 | [diff] [blame] | 792 | can place it under Git revision control as follows.</p></div> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 793 | <div class="listingblock"> |
| 794 | <div class="content"> |
Junio C Hamano | 446e30b | 2014-10-16 21:30:32 | [diff] [blame] | 795 | <pre><code>$ tar xzf project.tar.gz |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 796 | $ cd project |
Junio C Hamano | 446e30b | 2014-10-16 21:30:32 | [diff] [blame] | 797 | $ git init</code></pre> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 798 | </div></div> |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 799 | <div class="paragraph"><p>Git will reply</p></div> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 800 | <div class="listingblock"> |
| 801 | <div class="content"> |
Junio C Hamano | 446e30b | 2014-10-16 21:30:32 | [diff] [blame] | 802 | <pre><code>Initialized empty Git repository in .git/</code></pre> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 803 | </div></div> |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 804 | <div class="paragraph"><p>You’ve now initialized the working directory—you may notice a new |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 805 | directory created, named ".git".</p></div> |
Junio C Hamano | 076ffcc | 2013-02-06 05:13:21 | [diff] [blame] | 806 | <div class="paragraph"><p>Next, tell Git to take a snapshot of the contents of all files under the |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame] | 807 | current directory (note the <em>.</em>), with <em>git add</em>:</p></div> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 808 | <div class="listingblock"> |
| 809 | <div class="content"> |
Junio C Hamano | 446e30b | 2014-10-16 21:30:32 | [diff] [blame] | 810 | <pre><code>$ git add .</code></pre> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 811 | </div></div> |
Junio C Hamano | 076ffcc | 2013-02-06 05:13:21 | [diff] [blame] | 812 | <div class="paragraph"><p>This snapshot is now stored in a temporary staging area which Git calls |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 813 | the "index". You can permanently store the contents of the index in the |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame] | 814 | repository with <em>git commit</em>:</p></div> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 815 | <div class="listingblock"> |
| 816 | <div class="content"> |
Junio C Hamano | 446e30b | 2014-10-16 21:30:32 | [diff] [blame] | 817 | <pre><code>$ git commit</code></pre> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 818 | </div></div> |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 819 | <div class="paragraph"><p>This will prompt you for a commit message. You’ve now stored the first |
Junio C Hamano | 076ffcc | 2013-02-06 05:13:21 | [diff] [blame] | 820 | version of your project in Git.</p></div> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 821 | </div> |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 822 | </div> |
| 823 | <div class="sect1"> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 824 | <h2 id="_making_changes">Making changes</h2> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 825 | <div class="sectionbody"> |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 826 | <div class="paragraph"><p>Modify some files, then add their updated contents to the index:</p></div> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 827 | <div class="listingblock"> |
| 828 | <div class="content"> |
Junio C Hamano | 446e30b | 2014-10-16 21:30:32 | [diff] [blame] | 829 | <pre><code>$ git add file1 file2 file3</code></pre> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 830 | </div></div> |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 831 | <div class="paragraph"><p>You are now ready to commit. You can see what is about to be committed |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame] | 832 | using <em>git diff</em> with the --cached option:</p></div> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 833 | <div class="listingblock"> |
| 834 | <div class="content"> |
Junio C Hamano | 446e30b | 2014-10-16 21:30:32 | [diff] [blame] | 835 | <pre><code>$ git diff --cached</code></pre> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 836 | </div></div> |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 837 | <div class="paragraph"><p>(Without --cached, <em>git diff</em> will show you any changes that |
| 838 | you’ve made but not yet added to the index.) You can also get a brief |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame] | 839 | summary of the situation with <em>git status</em>:</p></div> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 840 | <div class="listingblock"> |
| 841 | <div class="content"> |
Junio C Hamano | 446e30b | 2014-10-16 21:30:32 | [diff] [blame] | 842 | <pre><code>$ git status |
Junio C Hamano | 1322024 | 2014-11-19 23:06:27 | [diff] [blame] | 843 | On branch master |
| 844 | Changes to be committed: |
Junio C Hamano | 88bf571 | 2017-09-10 08:39:23 | [diff] [blame] | 845 | Your branch is up to date with 'origin/master'. |
Junio C Hamano | c9f11c2 | 2019-07-10 02:54:04 | [diff] [blame] | 846 | (use "git restore --staged <file>..." to unstage) |
Junio C Hamano | 1322024 | 2014-11-19 23:06:27 | [diff] [blame] | 847 | |
| 848 | modified: file1 |
| 849 | modified: file2 |
| 850 | modified: file3</code></pre> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 851 | </div></div> |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 852 | <div class="paragraph"><p>If you need to make any further adjustments, do so now, and then add any |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 853 | newly modified content to the index. Finally, commit your changes with:</p></div> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 854 | <div class="listingblock"> |
| 855 | <div class="content"> |
Junio C Hamano | 446e30b | 2014-10-16 21:30:32 | [diff] [blame] | 856 | <pre><code>$ git commit</code></pre> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 857 | </div></div> |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 858 | <div class="paragraph"><p>This will again prompt you for a message describing the change, and then |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 859 | record a new version of the project.</p></div> |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 860 | <div class="paragraph"><p>Alternatively, instead of running <em>git add</em> beforehand, you can use</p></div> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 861 | <div class="listingblock"> |
| 862 | <div class="content"> |
Junio C Hamano | 446e30b | 2014-10-16 21:30:32 | [diff] [blame] | 863 | <pre><code>$ git commit -a</code></pre> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 864 | </div></div> |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 865 | <div class="paragraph"><p>which will automatically notice any modified (but not new) files, add |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 866 | them to the index, and commit, all in one step.</p></div> |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 867 | <div class="paragraph"><p>A note on commit messages: Though not required, it’s a good idea to |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 868 | begin the commit message with a single short (less than 50 character) |
| 869 | line summarizing the change, followed by a blank line and then a more |
Junio C Hamano | 281fd39 | 2012-09-17 23:57:41 | [diff] [blame] | 870 | thorough description. The text up to the first blank line in a commit |
| 871 | message is treated as the commit title, and that title is used |
Junio C Hamano | 076ffcc | 2013-02-06 05:13:21 | [diff] [blame] | 872 | throughout Git. For example, <a href="git-format-patch.html">git-format-patch(1)</a> turns a |
Junio C Hamano | 281fd39 | 2012-09-17 23:57:41 | [diff] [blame] | 873 | commit into email, and it uses the title on the Subject line and the |
| 874 | rest of the commit in the body.</p></div> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 875 | </div> |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 876 | </div> |
| 877 | <div class="sect1"> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 878 | <h2 id="_git_tracks_content_not_files">Git tracks content not files</h2> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 879 | <div class="sectionbody"> |
Junio C Hamano | 446e30b | 2014-10-16 21:30:32 | [diff] [blame] | 880 | <div class="paragraph"><p>Many revision control systems provide an <code>add</code> command that tells the |
| 881 | system to start tracking changes to a new file. Git’s <code>add</code> command |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame] | 882 | does something simpler and more powerful: <em>git add</em> is used both for new |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 883 | and newly modified files, and in both cases it takes a snapshot of the |
| 884 | given files and stages that content in the index, ready for inclusion in |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 885 | the next commit.</p></div> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 886 | </div> |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 887 | </div> |
| 888 | <div class="sect1"> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 889 | <h2 id="_viewing_project_history">Viewing project history</h2> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 890 | <div class="sectionbody"> |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 891 | <div class="paragraph"><p>At any point you can view the history of your changes using</p></div> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 892 | <div class="listingblock"> |
| 893 | <div class="content"> |
Junio C Hamano | 446e30b | 2014-10-16 21:30:32 | [diff] [blame] | 894 | <pre><code>$ git log</code></pre> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 895 | </div></div> |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 896 | <div class="paragraph"><p>If you also want to see complete diffs at each step, use</p></div> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 897 | <div class="listingblock"> |
| 898 | <div class="content"> |
Junio C Hamano | 446e30b | 2014-10-16 21:30:32 | [diff] [blame] | 899 | <pre><code>$ git log -p</code></pre> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 900 | </div></div> |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 901 | <div class="paragraph"><p>Often the overview of the change is useful to get a feel of |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 902 | each step</p></div> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 903 | <div class="listingblock"> |
| 904 | <div class="content"> |
Junio C Hamano | 446e30b | 2014-10-16 21:30:32 | [diff] [blame] | 905 | <pre><code>$ git log --stat --summary</code></pre> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 906 | </div></div> |
| 907 | </div> |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 908 | </div> |
| 909 | <div class="sect1"> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 910 | <h2 id="_managing_branches">Managing branches</h2> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 911 | <div class="sectionbody"> |
Junio C Hamano | 076ffcc | 2013-02-06 05:13:21 | [diff] [blame] | 912 | <div class="paragraph"><p>A single Git repository can maintain multiple branches of |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 913 | development. To create a new branch named "experimental", use</p></div> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 914 | <div class="listingblock"> |
| 915 | <div class="content"> |
Junio C Hamano | 446e30b | 2014-10-16 21:30:32 | [diff] [blame] | 916 | <pre><code>$ git branch experimental</code></pre> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 917 | </div></div> |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 918 | <div class="paragraph"><p>If you now run</p></div> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 919 | <div class="listingblock"> |
| 920 | <div class="content"> |
Junio C Hamano | 446e30b | 2014-10-16 21:30:32 | [diff] [blame] | 921 | <pre><code>$ git branch</code></pre> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 922 | </div></div> |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 923 | <div class="paragraph"><p>you’ll get a list of all existing branches:</p></div> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 924 | <div class="listingblock"> |
| 925 | <div class="content"> |
Junio C Hamano | 446e30b | 2014-10-16 21:30:32 | [diff] [blame] | 926 | <pre><code> experimental |
| 927 | * master</code></pre> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 928 | </div></div> |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 929 | <div class="paragraph"><p>The "experimental" branch is the one you just created, and the |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 930 | "master" branch is a default branch that was created for you |
| 931 | automatically. The asterisk marks the branch you are currently on; |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 932 | type</p></div> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 933 | <div class="listingblock"> |
| 934 | <div class="content"> |
Junio C Hamano | c9f11c2 | 2019-07-10 02:54:04 | [diff] [blame] | 935 | <pre><code>$ git switch experimental</code></pre> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 936 | </div></div> |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 937 | <div class="paragraph"><p>to switch to the experimental branch. Now edit a file, commit the |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 938 | change, and switch back to the master branch:</p></div> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 939 | <div class="listingblock"> |
| 940 | <div class="content"> |
Junio C Hamano | 446e30b | 2014-10-16 21:30:32 | [diff] [blame] | 941 | <pre><code>(edit file) |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 942 | $ git commit -a |
Junio C Hamano | c9f11c2 | 2019-07-10 02:54:04 | [diff] [blame] | 943 | $ git switch master</code></pre> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 944 | </div></div> |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 945 | <div class="paragraph"><p>Check that the change you made is no longer visible, since it was |
| 946 | made on the experimental branch and you’re back on the master branch.</p></div> |
| 947 | <div class="paragraph"><p>You can make a different change on the master branch:</p></div> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 948 | <div class="listingblock"> |
| 949 | <div class="content"> |
Junio C Hamano | 446e30b | 2014-10-16 21:30:32 | [diff] [blame] | 950 | <pre><code>(edit file) |
| 951 | $ git commit -a</code></pre> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 952 | </div></div> |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 953 | <div class="paragraph"><p>at this point the two branches have diverged, with different changes |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 954 | made in each. To merge the changes made in experimental into master, run</p></div> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 955 | <div class="listingblock"> |
| 956 | <div class="content"> |
Junio C Hamano | 446e30b | 2014-10-16 21:30:32 | [diff] [blame] | 957 | <pre><code>$ git merge experimental</code></pre> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 958 | </div></div> |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 959 | <div class="paragraph"><p>If the changes don’t conflict, you’re done. If there are conflicts, |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 960 | markers will be left in the problematic files showing the conflict;</p></div> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 961 | <div class="listingblock"> |
| 962 | <div class="content"> |
Junio C Hamano | 446e30b | 2014-10-16 21:30:32 | [diff] [blame] | 963 | <pre><code>$ git diff</code></pre> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 964 | </div></div> |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 965 | <div class="paragraph"><p>will show this. Once you’ve edited the files to resolve the |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 966 | conflicts,</p></div> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 967 | <div class="listingblock"> |
| 968 | <div class="content"> |
Junio C Hamano | 446e30b | 2014-10-16 21:30:32 | [diff] [blame] | 969 | <pre><code>$ git commit -a</code></pre> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 970 | </div></div> |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 971 | <div class="paragraph"><p>will commit the result of the merge. Finally,</p></div> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 972 | <div class="listingblock"> |
| 973 | <div class="content"> |
Junio C Hamano | 446e30b | 2014-10-16 21:30:32 | [diff] [blame] | 974 | <pre><code>$ gitk</code></pre> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 975 | </div></div> |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 976 | <div class="paragraph"><p>will show a nice graphical representation of the resulting history.</p></div> |
| 977 | <div class="paragraph"><p>At this point you could delete the experimental branch with</p></div> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 978 | <div class="listingblock"> |
| 979 | <div class="content"> |
Junio C Hamano | 446e30b | 2014-10-16 21:30:32 | [diff] [blame] | 980 | <pre><code>$ git branch -d experimental</code></pre> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 981 | </div></div> |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 982 | <div class="paragraph"><p>This command ensures that the changes in the experimental branch are |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 983 | already in the current branch.</p></div> |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 984 | <div class="paragraph"><p>If you develop on a branch crazy-idea, then regret it, you can always |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 985 | delete the branch with</p></div> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 986 | <div class="listingblock"> |
| 987 | <div class="content"> |
Junio C Hamano | 446e30b | 2014-10-16 21:30:32 | [diff] [blame] | 988 | <pre><code>$ git branch -D crazy-idea</code></pre> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 989 | </div></div> |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 990 | <div class="paragraph"><p>Branches are cheap and easy, so this is a good way to try something |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 991 | out.</p></div> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 992 | </div> |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 993 | </div> |
| 994 | <div class="sect1"> |
Junio C Hamano | 076ffcc | 2013-02-06 05:13:21 | [diff] [blame] | 995 | <h2 id="_using_git_for_collaboration">Using Git for collaboration</h2> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 996 | <div class="sectionbody"> |
Junio C Hamano | 076ffcc | 2013-02-06 05:13:21 | [diff] [blame] | 997 | <div class="paragraph"><p>Suppose that Alice has started a new project with a Git repository in |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 998 | /home/alice/project, and that Bob, who has a home directory on the |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 999 | same machine, wants to contribute.</p></div> |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 1000 | <div class="paragraph"><p>Bob begins with:</p></div> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 1001 | <div class="listingblock"> |
| 1002 | <div class="content"> |
Junio C Hamano | 446e30b | 2014-10-16 21:30:32 | [diff] [blame] | 1003 | <pre><code>bob$ git clone /home/alice/project myrepo</code></pre> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 1004 | </div></div> |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 1005 | <div class="paragraph"><p>This creates a new directory "myrepo" containing a clone of Alice’s |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 1006 | repository. The clone is on an equal footing with the original |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 1007 | project, possessing its own copy of the original project’s history.</p></div> |
| 1008 | <div class="paragraph"><p>Bob then makes some changes and commits them:</p></div> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 1009 | <div class="listingblock"> |
| 1010 | <div class="content"> |
Junio C Hamano | 446e30b | 2014-10-16 21:30:32 | [diff] [blame] | 1011 | <pre><code>(edit files) |
Junio C Hamano | 38ddcce | 2008-07-15 15:49:03 | [diff] [blame] | 1012 | bob$ git commit -a |
Junio C Hamano | 446e30b | 2014-10-16 21:30:32 | [diff] [blame] | 1013 | (repeat as necessary)</code></pre> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 1014 | </div></div> |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 1015 | <div class="paragraph"><p>When he’s ready, he tells Alice to pull changes from the repository |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1016 | at /home/bob/myrepo. She does this with:</p></div> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 1017 | <div class="listingblock"> |
| 1018 | <div class="content"> |
Junio C Hamano | 446e30b | 2014-10-16 21:30:32 | [diff] [blame] | 1019 | <pre><code>alice$ cd /home/alice/project |
| 1020 | alice$ git pull /home/bob/myrepo master</code></pre> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 1021 | </div></div> |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 1022 | <div class="paragraph"><p>This merges the changes from Bob’s "master" branch into Alice’s |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 1023 | current branch. If Alice has made her own changes in the meantime, |
Junio C Hamano | 20d47e3 | 2009-01-26 06:36:02 | [diff] [blame] | 1024 | then she may need to manually fix any conflicts.</p></div> |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 1025 | <div class="paragraph"><p>The "pull" command thus performs two operations: it fetches changes |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1026 | from a remote branch, then merges them into the current branch.</p></div> |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 1027 | <div class="paragraph"><p>Note that in general, Alice would want her local changes committed before |
| 1028 | initiating this "pull". If Bob’s work conflicts with what Alice did since |
Junio C Hamano | 38ddcce | 2008-07-15 15:49:03 | [diff] [blame] | 1029 | their histories forked, Alice will use her working tree and the index to |
| 1030 | resolve conflicts, and existing local changes will interfere with the |
Junio C Hamano | 076ffcc | 2013-02-06 05:13:21 | [diff] [blame] | 1031 | conflict resolution process (Git will still perform the fetch but will |
Junio C Hamano | 38ddcce | 2008-07-15 15:49:03 | [diff] [blame] | 1032 | refuse to merge --- Alice will have to get rid of her local changes in |
| 1033 | some way and pull again when this happens).</p></div> |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 1034 | <div class="paragraph"><p>Alice can peek at what Bob did without merging first, using the "fetch" |
Junio C Hamano | 38ddcce | 2008-07-15 15:49:03 | [diff] [blame] | 1035 | command; this allows Alice to inspect what Bob did, using a special |
| 1036 | symbol "FETCH_HEAD", in order to determine if he has anything worth |
| 1037 | pulling, like this:</p></div> |
| 1038 | <div class="listingblock"> |
| 1039 | <div class="content"> |
Junio C Hamano | 446e30b | 2014-10-16 21:30:32 | [diff] [blame] | 1040 | <pre><code>alice$ git fetch /home/bob/myrepo master |
| 1041 | alice$ git log -p HEAD..FETCH_HEAD</code></pre> |
Junio C Hamano | 38ddcce | 2008-07-15 15:49:03 | [diff] [blame] | 1042 | </div></div> |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 1043 | <div class="paragraph"><p>This operation is safe even if Alice has uncommitted local changes. |
Junio C Hamano | 73d812c | 2009-07-01 02:33:06 | [diff] [blame] | 1044 | The range notation "HEAD..FETCH_HEAD" means "show everything that is reachable |
| 1045 | from the FETCH_HEAD but exclude anything that is reachable from HEAD". |
Junio C Hamano | a387df3 | 2008-08-29 08:56:58 | [diff] [blame] | 1046 | Alice already knows everything that leads to her current state (HEAD), |
Junio C Hamano | 73d812c | 2009-07-01 02:33:06 | [diff] [blame] | 1047 | and reviews what Bob has in his state (FETCH_HEAD) that she has not |
| 1048 | seen with this command.</p></div> |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 1049 | <div class="paragraph"><p>If Alice wants to visualize what Bob did since their histories forked |
Junio C Hamano | a387df3 | 2008-08-29 08:56:58 | [diff] [blame] | 1050 | she can issue the following command:</p></div> |
| 1051 | <div class="listingblock"> |
| 1052 | <div class="content"> |
Junio C Hamano | 446e30b | 2014-10-16 21:30:32 | [diff] [blame] | 1053 | <pre><code>$ gitk HEAD..FETCH_HEAD</code></pre> |
Junio C Hamano | a387df3 | 2008-08-29 08:56:58 | [diff] [blame] | 1054 | </div></div> |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 1055 | <div class="paragraph"><p>This uses the same two-dot range notation we saw earlier with <em>git log</em>.</p></div> |
| 1056 | <div class="paragraph"><p>Alice may want to view what both of them did since they forked. |
Junio C Hamano | a387df3 | 2008-08-29 08:56:58 | [diff] [blame] | 1057 | She can use three-dot form instead of the two-dot form:</p></div> |
| 1058 | <div class="listingblock"> |
| 1059 | <div class="content"> |
Junio C Hamano | 446e30b | 2014-10-16 21:30:32 | [diff] [blame] | 1060 | <pre><code>$ gitk HEAD...FETCH_HEAD</code></pre> |
Junio C Hamano | a387df3 | 2008-08-29 08:56:58 | [diff] [blame] | 1061 | </div></div> |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 1062 | <div class="paragraph"><p>This means "show everything that is reachable from either one, but |
Junio C Hamano | a387df3 | 2008-08-29 08:56:58 | [diff] [blame] | 1063 | exclude anything that is reachable from both of them".</p></div> |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 1064 | <div class="paragraph"><p>Please note that these range notation can be used with both gitk |
Junio C Hamano | a387df3 | 2008-08-29 08:56:58 | [diff] [blame] | 1065 | and "git log".</p></div> |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 1066 | <div class="paragraph"><p>After inspecting what Bob did, if there is nothing urgent, Alice may |
| 1067 | decide to continue working without pulling from Bob. If Bob’s history |
Junio C Hamano | 38ddcce | 2008-07-15 15:49:03 | [diff] [blame] | 1068 | does have something Alice would immediately need, Alice may choose to |
| 1069 | stash her work-in-progress first, do a "pull", and then finally unstash |
| 1070 | her work-in-progress on top of the resulting history.</p></div> |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 1071 | <div class="paragraph"><p>When you are working in a small closely knit group, it is not |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 1072 | unusual to interact with the same repository over and over |
| 1073 | again. By defining <em>remote</em> repository shorthand, you can make |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1074 | it easier:</p></div> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 1075 | <div class="listingblock"> |
| 1076 | <div class="content"> |
Junio C Hamano | 446e30b | 2014-10-16 21:30:32 | [diff] [blame] | 1077 | <pre><code>alice$ git remote add bob /home/bob/myrepo</code></pre> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 1078 | </div></div> |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 1079 | <div class="paragraph"><p>With this, Alice can perform the first part of the "pull" operation |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame] | 1080 | alone using the <em>git fetch</em> command without merging them with her own |
Junio C Hamano | 73d812c | 2009-07-01 02:33:06 | [diff] [blame] | 1081 | branch, using:</p></div> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 1082 | <div class="listingblock"> |
| 1083 | <div class="content"> |
Junio C Hamano | 446e30b | 2014-10-16 21:30:32 | [diff] [blame] | 1084 | <pre><code>alice$ git fetch bob</code></pre> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 1085 | </div></div> |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 1086 | <div class="paragraph"><p>Unlike the longhand form, when Alice fetches from Bob using a |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame] | 1087 | remote repository shorthand set up with <em>git remote</em>, what was |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 1088 | fetched is stored in a remote-tracking branch, in this case |
Junio C Hamano | 446e30b | 2014-10-16 21:30:32 | [diff] [blame] | 1089 | <code>bob/master</code>. So after this:</p></div> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 1090 | <div class="listingblock"> |
| 1091 | <div class="content"> |
Junio C Hamano | 446e30b | 2014-10-16 21:30:32 | [diff] [blame] | 1092 | <pre><code>alice$ git log -p master..bob/master</code></pre> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 1093 | </div></div> |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 1094 | <div class="paragraph"><p>shows a list of all the changes that Bob made since he branched from |
| 1095 | Alice’s master branch.</p></div> |
| 1096 | <div class="paragraph"><p>After examining those changes, Alice |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1097 | could merge the changes into her master branch:</p></div> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 1098 | <div class="listingblock"> |
| 1099 | <div class="content"> |
Junio C Hamano | 446e30b | 2014-10-16 21:30:32 | [diff] [blame] | 1100 | <pre><code>alice$ git merge bob/master</code></pre> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 1101 | </div></div> |
Junio C Hamano | 446e30b | 2014-10-16 21:30:32 | [diff] [blame] | 1102 | <div class="paragraph"><p>This <code>merge</code> can also be done by <em>pulling from her own remote-tracking |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 1103 | branch</em>, like this:</p></div> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 1104 | <div class="listingblock"> |
| 1105 | <div class="content"> |
Junio C Hamano | 446e30b | 2014-10-16 21:30:32 | [diff] [blame] | 1106 | <pre><code>alice$ git pull . remotes/bob/master</code></pre> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 1107 | </div></div> |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 1108 | <div class="paragraph"><p>Note that git pull always merges into the current branch, |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1109 | regardless of what else is given on the command line.</p></div> |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 1110 | <div class="paragraph"><p>Later, Bob can update his repo with Alice’s latest changes using</p></div> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 1111 | <div class="listingblock"> |
| 1112 | <div class="content"> |
Junio C Hamano | 446e30b | 2014-10-16 21:30:32 | [diff] [blame] | 1113 | <pre><code>bob$ git pull</code></pre> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 1114 | </div></div> |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 1115 | <div class="paragraph"><p>Note that he doesn’t need to give the path to Alice’s repository; |
Junio C Hamano | 076ffcc | 2013-02-06 05:13:21 | [diff] [blame] | 1116 | when Bob cloned Alice’s repository, Git stored the location of her |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 1117 | repository in the repository configuration, and that location is |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1118 | used for pulls:</p></div> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 1119 | <div class="listingblock"> |
| 1120 | <div class="content"> |
Junio C Hamano | 446e30b | 2014-10-16 21:30:32 | [diff] [blame] | 1121 | <pre><code>bob$ git config --get remote.origin.url |
| 1122 | /home/alice/project</code></pre> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 1123 | </div></div> |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 1124 | <div class="paragraph"><p>(The complete configuration created by <em>git clone</em> is visible using |
Junio C Hamano | 446e30b | 2014-10-16 21:30:32 | [diff] [blame] | 1125 | <code>git config -l</code>, and the <a href="git-config.html">git-config(1)</a> man page |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1126 | explains the meaning of each option.)</p></div> |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 1127 | <div class="paragraph"><p>Git also keeps a pristine copy of Alice’s master branch under the |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1128 | name "origin/master":</p></div> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 1129 | <div class="listingblock"> |
| 1130 | <div class="content"> |
Junio C Hamano | 446e30b | 2014-10-16 21:30:32 | [diff] [blame] | 1131 | <pre><code>bob$ git branch -r |
| 1132 | origin/master</code></pre> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 1133 | </div></div> |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 1134 | <div class="paragraph"><p>If Bob later decides to work from a different host, he can still |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1135 | perform clones and pulls using the ssh protocol:</p></div> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 1136 | <div class="listingblock"> |
| 1137 | <div class="content"> |
Junio C Hamano | 446e30b | 2014-10-16 21:30:32 | [diff] [blame] | 1138 | <pre><code>bob$ git clone alice.org:/home/alice/project myrepo</code></pre> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 1139 | </div></div> |
Junio C Hamano | f85ef63 | 2016-02-17 22:31:06 | [diff] [blame] | 1140 | <div class="paragraph"><p>Alternatively, Git has a native protocol, or can use http; |
Junio C Hamano | a28a920 | 2012-06-21 07:08:23 | [diff] [blame] | 1141 | see <a href="git-pull.html">git-pull(1)</a> for details.</p></div> |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 1142 | <div class="paragraph"><p>Git can also be used in a CVS-like mode, with a central repository |
Junio C Hamano | a28a920 | 2012-06-21 07:08:23 | [diff] [blame] | 1143 | that various users push changes to; see <a href="git-push.html">git-push(1)</a> and |
| 1144 | <a href="gitcvs-migration.html">gitcvs-migration(7)</a>.</p></div> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 1145 | </div> |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 1146 | </div> |
| 1147 | <div class="sect1"> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1148 | <h2 id="_exploring_history">Exploring history</h2> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 1149 | <div class="sectionbody"> |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 1150 | <div class="paragraph"><p>Git history is represented as a series of interrelated commits. We |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame] | 1151 | have already seen that the <em>git log</em> command can list those commits. |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 1152 | Note that first line of each git log entry also gives a name for the |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1153 | commit:</p></div> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 1154 | <div class="listingblock"> |
| 1155 | <div class="content"> |
Junio C Hamano | 446e30b | 2014-10-16 21:30:32 | [diff] [blame] | 1156 | <pre><code>$ git log |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 1157 | commit c82a22c39cbc32576f64f5c6b3f24b99ea8149c7 |
| 1158 | Author: Junio C Hamano <junkio@cox.net> |
| 1159 | Date: Tue May 16 17:18:22 2006 -0700 |
| 1160 | |
Junio C Hamano | 446e30b | 2014-10-16 21:30:32 | [diff] [blame] | 1161 | merge-base: Clarify the comments on post processing.</code></pre> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 1162 | </div></div> |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 1163 | <div class="paragraph"><p>We can give this name to <em>git show</em> to see the details about this |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1164 | commit.</p></div> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 1165 | <div class="listingblock"> |
| 1166 | <div class="content"> |
Junio C Hamano | 446e30b | 2014-10-16 21:30:32 | [diff] [blame] | 1167 | <pre><code>$ git show c82a22c39cbc32576f64f5c6b3f24b99ea8149c7</code></pre> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 1168 | </div></div> |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 1169 | <div class="paragraph"><p>But there are other ways to refer to commits. You can use any initial |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1170 | part of the name that is long enough to uniquely identify the commit:</p></div> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 1171 | <div class="listingblock"> |
| 1172 | <div class="content"> |
Junio C Hamano | 446e30b | 2014-10-16 21:30:32 | [diff] [blame] | 1173 | <pre><code>$ git show c82a22c39c # the first few characters of the name are |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 1174 | # usually enough |
| 1175 | $ git show HEAD # the tip of the current branch |
Junio C Hamano | 446e30b | 2014-10-16 21:30:32 | [diff] [blame] | 1176 | $ git show experimental # the tip of the "experimental" branch</code></pre> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 1177 | </div></div> |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 1178 | <div class="paragraph"><p>Every commit usually has one "parent" commit |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1179 | which points to the previous state of the project:</p></div> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 1180 | <div class="listingblock"> |
| 1181 | <div class="content"> |
Junio C Hamano | 446e30b | 2014-10-16 21:30:32 | [diff] [blame] | 1182 | <pre><code>$ git show HEAD^ # to see the parent of HEAD |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 1183 | $ git show HEAD^^ # to see the grandparent of HEAD |
Junio C Hamano | 446e30b | 2014-10-16 21:30:32 | [diff] [blame] | 1184 | $ git show HEAD~4 # to see the great-great grandparent of HEAD</code></pre> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 1185 | </div></div> |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 1186 | <div class="paragraph"><p>Note that merge commits may have more than one parent:</p></div> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 1187 | <div class="listingblock"> |
| 1188 | <div class="content"> |
Junio C Hamano | 446e30b | 2014-10-16 21:30:32 | [diff] [blame] | 1189 | <pre><code>$ git show HEAD^1 # show the first parent of HEAD (same as HEAD^) |
| 1190 | $ git show HEAD^2 # show the second parent of HEAD</code></pre> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 1191 | </div></div> |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 1192 | <div class="paragraph"><p>You can also give commits names of your own; after running</p></div> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 1193 | <div class="listingblock"> |
| 1194 | <div class="content"> |
Junio C Hamano | 446e30b | 2014-10-16 21:30:32 | [diff] [blame] | 1195 | <pre><code>$ git tag v2.5 1b2e1d63ff</code></pre> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 1196 | </div></div> |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 1197 | <div class="paragraph"><p>you can refer to 1b2e1d63ff by the name "v2.5". If you intend to |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 1198 | share this name with other people (for example, to identify a release |
| 1199 | version), you should create a "tag" object, and perhaps sign it; see |
Junio C Hamano | a28a920 | 2012-06-21 07:08:23 | [diff] [blame] | 1200 | <a href="git-tag.html">git-tag(1)</a> for details.</p></div> |
Junio C Hamano | 076ffcc | 2013-02-06 05:13:21 | [diff] [blame] | 1201 | <div class="paragraph"><p>Any Git command that needs to know a commit can take any of these |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1202 | names. For example:</p></div> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 1203 | <div class="listingblock"> |
| 1204 | <div class="content"> |
Junio C Hamano | 446e30b | 2014-10-16 21:30:32 | [diff] [blame] | 1205 | <pre><code>$ git diff v2.5 HEAD # compare the current HEAD to v2.5 |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 1206 | $ git branch stable v2.5 # start a new branch named "stable" based |
| 1207 | # at v2.5 |
| 1208 | $ git reset --hard HEAD^ # reset your current branch and working |
Junio C Hamano | 446e30b | 2014-10-16 21:30:32 | [diff] [blame] | 1209 | # directory to its state at HEAD^</code></pre> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 1210 | </div></div> |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 1211 | <div class="paragraph"><p>Be careful with that last command: in addition to losing any changes |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 1212 | in the working directory, it will also remove all later commits from |
| 1213 | this branch. If this branch is the only branch containing those |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 1214 | commits, they will be lost. Also, don’t use <em>git reset</em> on a |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 1215 | publicly-visible branch that other developers pull from, as it will |
| 1216 | force needless merges on other developers to clean up the history. |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame] | 1217 | If you need to undo changes that you have pushed, use <em>git revert</em> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1218 | instead.</p></div> |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 1219 | <div class="paragraph"><p>The <em>git grep</em> command can search for strings in any version of your |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1220 | project, so</p></div> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 1221 | <div class="listingblock"> |
| 1222 | <div class="content"> |
Junio C Hamano | 446e30b | 2014-10-16 21:30:32 | [diff] [blame] | 1223 | <pre><code>$ git grep "hello" v2.5</code></pre> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 1224 | </div></div> |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 1225 | <div class="paragraph"><p>searches for all occurrences of "hello" in v2.5.</p></div> |
| 1226 | <div class="paragraph"><p>If you leave out the commit name, <em>git grep</em> will search any of the |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1227 | files it manages in your current directory. So</p></div> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 1228 | <div class="listingblock"> |
| 1229 | <div class="content"> |
Junio C Hamano | 446e30b | 2014-10-16 21:30:32 | [diff] [blame] | 1230 | <pre><code>$ git grep "hello"</code></pre> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 1231 | </div></div> |
Junio C Hamano | 076ffcc | 2013-02-06 05:13:21 | [diff] [blame] | 1232 | <div class="paragraph"><p>is a quick way to search just the files that are tracked by Git.</p></div> |
| 1233 | <div class="paragraph"><p>Many Git commands also take sets of commits, which can be specified |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame] | 1234 | in a number of ways. Here are some examples with <em>git log</em>:</p></div> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 1235 | <div class="listingblock"> |
| 1236 | <div class="content"> |
Junio C Hamano | 446e30b | 2014-10-16 21:30:32 | [diff] [blame] | 1237 | <pre><code>$ git log v2.5..v2.6 # commits between v2.5 and v2.6 |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 1238 | $ git log v2.5.. # commits since v2.5 |
| 1239 | $ git log --since="2 weeks ago" # commits from the last 2 weeks |
| 1240 | $ git log v2.5.. Makefile # commits since v2.5 which modify |
Junio C Hamano | 446e30b | 2014-10-16 21:30:32 | [diff] [blame] | 1241 | # Makefile</code></pre> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 1242 | </div></div> |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 1243 | <div class="paragraph"><p>You can also give <em>git log</em> a "range" of commits where the first is not |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 1244 | necessarily an ancestor of the second; for example, if the tips of |
Junio C Hamano | 73d812c | 2009-07-01 02:33:06 | [diff] [blame] | 1245 | the branches "stable" and "master" diverged from a common |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1246 | commit some time ago, then</p></div> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 1247 | <div class="listingblock"> |
| 1248 | <div class="content"> |
Junio C Hamano | 446e30b | 2014-10-16 21:30:32 | [diff] [blame] | 1249 | <pre><code>$ git log stable..master</code></pre> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 1250 | </div></div> |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 1251 | <div class="paragraph"><p>will list commits made in the master branch but not in the |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1252 | stable branch, while</p></div> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 1253 | <div class="listingblock"> |
| 1254 | <div class="content"> |
Junio C Hamano | 446e30b | 2014-10-16 21:30:32 | [diff] [blame] | 1255 | <pre><code>$ git log master..stable</code></pre> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 1256 | </div></div> |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 1257 | <div class="paragraph"><p>will show the list of commits made on the stable branch but not |
Junio C Hamano | 73d812c | 2009-07-01 02:33:06 | [diff] [blame] | 1258 | the master branch.</p></div> |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 1259 | <div class="paragraph"><p>The <em>git log</em> command has a weakness: it must present commits in a |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 1260 | list. When the history has lines of development that diverged and |
Junio C Hamano | 1aa40d2 | 2010-01-21 17:46:43 | [diff] [blame] | 1261 | then merged back together, the order in which <em>git log</em> presents |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1262 | those commits is meaningless.</p></div> |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 1263 | <div class="paragraph"><p>Most projects with multiple contributors (such as the Linux kernel, |
Junio C Hamano | 076ffcc | 2013-02-06 05:13:21 | [diff] [blame] | 1264 | or Git itself) have frequent merges, and <em>gitk</em> does a better job of |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1265 | visualizing their history. For example,</p></div> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 1266 | <div class="listingblock"> |
| 1267 | <div class="content"> |
Junio C Hamano | 446e30b | 2014-10-16 21:30:32 | [diff] [blame] | 1268 | <pre><code>$ gitk --since="2 weeks ago" drivers/</code></pre> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 1269 | </div></div> |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 1270 | <div class="paragraph"><p>allows you to browse any commits from the last 2 weeks of commits |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 1271 | that modified files under the "drivers" directory. (Note: you can |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 1272 | adjust gitk’s fonts by holding down the control key while pressing |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1273 | "-" or "+".)</p></div> |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 1274 | <div class="paragraph"><p>Finally, most commands that take filenames will optionally allow you |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 1275 | to precede any filename by a commit, to specify a particular version |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1276 | of the file:</p></div> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 1277 | <div class="listingblock"> |
| 1278 | <div class="content"> |
Junio C Hamano | 446e30b | 2014-10-16 21:30:32 | [diff] [blame] | 1279 | <pre><code>$ git diff v2.5:Makefile HEAD:Makefile.in</code></pre> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 1280 | </div></div> |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 1281 | <div class="paragraph"><p>You can also use <em>git show</em> to see any such file:</p></div> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 1282 | <div class="listingblock"> |
| 1283 | <div class="content"> |
Junio C Hamano | 446e30b | 2014-10-16 21:30:32 | [diff] [blame] | 1284 | <pre><code>$ git show v2.5:Makefile</code></pre> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 1285 | </div></div> |
| 1286 | </div> |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 1287 | </div> |
| 1288 | <div class="sect1"> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1289 | <h2 id="_next_steps">Next Steps</h2> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 1290 | <div class="sectionbody"> |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 1291 | <div class="paragraph"><p>This tutorial should be enough to perform basic distributed revision |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 1292 | control for your projects. However, to fully understand the depth |
Junio C Hamano | 076ffcc | 2013-02-06 05:13:21 | [diff] [blame] | 1293 | and power of Git you need to understand two simple ideas on which it |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1294 | is based:</p></div> |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 1295 | <div class="ulist"><ul> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 1296 | <li> |
| 1297 | <p> |
| 1298 | The object database is the rather elegant system used to |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 1299 | store the history of your project—files, directories, and |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 1300 | commits. |
| 1301 | </p> |
| 1302 | </li> |
| 1303 | <li> |
| 1304 | <p> |
| 1305 | The index file is a cache of the state of a directory tree, |
| 1306 | used to create commits, check out working directories, and |
| 1307 | hold the various trees involved in a merge. |
| 1308 | </p> |
| 1309 | </li> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1310 | </ul></div> |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 1311 | <div class="paragraph"><p>Part two of this tutorial explains the object |
| 1312 | database, the index file, and a few other odds and ends that you’ll |
Junio C Hamano | 076ffcc | 2013-02-06 05:13:21 | [diff] [blame] | 1313 | need to make the most of Git. You can find it at <a href="gittutorial-2.html">gittutorial-2(7)</a>.</p></div> |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 1314 | <div class="paragraph"><p>If you don’t want to continue with that right away, a few other |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1315 | digressions that may be interesting at this point are:</p></div> |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 1316 | <div class="ulist"><ul> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 1317 | <li> |
| 1318 | <p> |
Junio C Hamano | a28a920 | 2012-06-21 07:08:23 | [diff] [blame] | 1319 | <a href="git-format-patch.html">git-format-patch(1)</a>, <a href="git-am.html">git-am(1)</a>: These convert |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 1320 | series of git commits into emailed patches, and vice versa, |
Junio C Hamano | 4fbdd44 | 2009-01-06 05:56:24 | [diff] [blame] | 1321 | useful for projects such as the Linux kernel which rely heavily |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 1322 | on emailed patches. |
| 1323 | </p> |
| 1324 | </li> |
| 1325 | <li> |
| 1326 | <p> |
Junio C Hamano | a28a920 | 2012-06-21 07:08:23 | [diff] [blame] | 1327 | <a href="git-bisect.html">git-bisect(1)</a>: When there is a regression in your |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 1328 | project, one way to track down the bug is by searching through |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 1329 | the history to find the exact commit that’s to blame. Git bisect |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 1330 | can help you perform a binary search for that commit. It is |
| 1331 | smart enough to perform a close-to-optimal search even in the |
| 1332 | case of complex non-linear history with lots of merged branches. |
| 1333 | </p> |
| 1334 | </li> |
| 1335 | <li> |
| 1336 | <p> |
Junio C Hamano | a28a920 | 2012-06-21 07:08:23 | [diff] [blame] | 1337 | <a href="gitworkflows.html">gitworkflows(7)</a>: Gives an overview of recommended |
Junio C Hamano | 804b521 | 2009-06-07 16:05:03 | [diff] [blame] | 1338 | workflows. |
| 1339 | </p> |
| 1340 | </li> |
| 1341 | <li> |
| 1342 | <p> |
Junio C Hamano | 446e30b | 2014-10-16 21:30:32 | [diff] [blame] | 1343 | <a href="giteveryday.html">giteveryday(7)</a>: Everyday Git with 20 Commands Or So. |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 1344 | </p> |
| 1345 | </li> |
| 1346 | <li> |
| 1347 | <p> |
Junio C Hamano | a28a920 | 2012-06-21 07:08:23 | [diff] [blame] | 1348 | <a href="gitcvs-migration.html">gitcvs-migration(7)</a>: Git for CVS users. |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 1349 | </p> |
| 1350 | </li> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1351 | </ul></div> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 1352 | </div> |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 1353 | </div> |
| 1354 | <div class="sect1"> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1355 | <h2 id="_see_also">SEE ALSO</h2> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 1356 | <div class="sectionbody"> |
Junio C Hamano | a28a920 | 2012-06-21 07:08:23 | [diff] [blame] | 1357 | <div class="paragraph"><p><a href="gittutorial-2.html">gittutorial-2(7)</a>, |
| 1358 | <a href="gitcvs-migration.html">gitcvs-migration(7)</a>, |
| 1359 | <a href="gitcore-tutorial.html">gitcore-tutorial(7)</a>, |
| 1360 | <a href="gitglossary.html">gitglossary(7)</a>, |
| 1361 | <a href="git-help.html">git-help(1)</a>, |
| 1362 | <a href="gitworkflows.html">gitworkflows(7)</a>, |
Junio C Hamano | 446e30b | 2014-10-16 21:30:32 | [diff] [blame] | 1363 | <a href="giteveryday.html">giteveryday(7)</a>, |
Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 1364 | <a href="user-manual.html">The Git User’s Manual</a></p></div> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 1365 | </div> |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 1366 | </div> |
| 1367 | <div class="sect1"> |
Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1368 | <h2 id="_git">GIT</h2> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 1369 | <div class="sectionbody"> |
Junio C Hamano | e89102f | 2017-02-15 23:18:15 | [diff] [blame] | 1370 | <div class="paragraph"><p>Part of the <a href="git.html">git(1)</a> suite</p></div> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 1371 | </div> |
Junio C Hamano | 7bd050f | 2011-09-22 06:32:22 | [diff] [blame] | 1372 | </div> |
Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 1373 | </div> |
Junio C Hamano | 7bd050f | 2011-09-22 06:32:22 | [diff] [blame] | 1374 | <div id="footnotes"><hr /></div> |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 1375 | <div id="footer"> |
| 1376 | <div id="footer-text"> |
Junio C Hamano | 2ef0ba3 | 2018-01-26 23:13:53 | [diff] [blame] | 1377 | Last updated |
Junio C Hamano | c9f11c2 | 2019-07-10 02:54:04 | [diff] [blame] | 1378 | 2019-07-09 19:51:04 PDT |
Junio C Hamano | dfccbb0 | 2008-05-26 01:16:14 | [diff] [blame] | 1379 | </div> |
| 1380 | </div> |
| 1381 | </body> |
| 1382 | </html> |