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